Maximum lines of code permitted in a Java class? -


how many lines of code can .java file contain? depend on jvm being used?

to extend upon jonas's response, java virtual machine specification, section 4.8 constraints on java virtual machine code says that:

the java virtual machine code method, instance initialization method (§3.9), or class or interface initialization method (§3.9) stored in code array of code attribute of method_info structure of class file. section describes constraints associated contents of code_attribute structure.

continuing section 4.8.1, static constraints

the static constraints on class file defining well-formedness of file. exception of static constraints on java virtual machine code of class file, these constraints have been given in previous section. static constraints on java virtual machine code in class file specify how java virtual machine instructions must laid out in code array , operands of individual instructions must be.

the static constraints on instructions in code array follows:

...

  • the value of code_length item must less 65536.

...

so method have limit of 65535 bytes of bytecode per method. (see note below)

for more limitations jvm, see section 4.10 limitations of java virtual machine.

note: although there apparently problem design of jvm, if instruction @ byte 65535 instruction 1 byte long, not protected exception handler - listed in footnote 4 of section 4.10.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -