java - What's the purpose of the method bytecode limit? -
following on this question: there 64kb bytecode limit on java methods.
what benefit provide compiler? gcc happily compile multi-megabyte c methods -- what's reasoning behind design decision? just, suggested in this question, limit poor programming practices, since 64kb methods massive? or there specific benefit limit being 64kb rather other number?
offsets in method bytecode 2 bytes long (called "u2" in class file format specification). maximum offset can expressed u2 64kb.
the offsets appear in actual instructions, such if*
bytecodes, followed 2 bytes containing offset delta of branch. also, other class file attributes stackmaptable
, localvariabletable
, exceptions
, others contain offsets bytecode.
if offsets u4, methods longer, all class files larger. it's trade-off.
Comments
Post a Comment