Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To extend upon <a href="https://stackoverflow.com/questions/107855/is-there-any-no-of-lines-code-limit-for-a-java-class#107870" title="Jonas&#39; response">Jonas's response</a>, the Java Virtual Machine Specification, <a href="http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#40222" rel="nofollow noreferrer" title="Section 4.8 Constraints on Java Virtual Machine Code">Section 4.8 Constraints on Java Virtual Machine Code</a> says that:</p> <blockquote> <p>The Java virtual machine code for a method, instance initialization method (§3.9), or class or interface initialization method (§3.9) is stored in the code array of the Code attribute of a method_info structure of a class file. This section describes the constraints associated with the contents of the Code_attribute structure.</p> </blockquote> <p>Continuing to Section 4.8.1, Static Constraints</p> <blockquote> <p>The static constraints on a class file are those defining the well-formedness of the file. With the exception of the static constraints on the Java virtual machine code of the class file, these constraints have been given in the previous section. The static constraints on the Java virtual machine code in a class file specify how Java virtual machine instructions must be laid out in the code array and what the operands of individual instructions must be.</p> <p>The static constraints on the instructions in the code array are as follows:</p> <p>...</p> <ul> <li>The value of the code_length item must be less than 65536.</li> </ul> <p>...</p> </blockquote> <p>So a method does have a limit of 65535 bytes of bytecode per method. (see note below)</p> <p>For more limitations to the JVM, see <a href="http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#88659" rel="nofollow noreferrer" title="4.10 Limitations of the Java Virtual Machine">Section 4.10 Limitations of the Java Virtual Machine</a>.</p> <p>Note: Although there is apparently a problem with the design of the JVM, where if the instruction at byte 65535 is an instruction that is 1 byte long, it is not protected by exception handler - this is listed in footnote 4 of Section 4.10.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload