“Code too large” compilation error in Java

后端 未结 13 1193
半阙折子戏
半阙折子戏 2020-11-22 14:33

Is there any maximum size for code in Java? I wrote a function with more than 10,000 lines. Actually, each line assigns a value to an array variable.

arts_b         


        
13条回答
  •  北海茫月
    2020-11-22 15:10

    According to the Java Virtual Machine specification, the code of a method must not be bigger than 65536 bytes:

    The value of the code_length item gives the number of bytes in the code array for this method.

    The value of code_length must be greater than zero (as the code array must not be empty) and less than 65536.

    code_length defines the size of the code[] attribute which contains the actual bytecode of a method:

    The code array gives the actual bytes of Java Virtual Machine code that implement the method.

提交回复
热议问题