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
Try to refactor your code. There is limit on the size of method in Java.
As there is a size limit for methods and you don't want to redesign your code as this moment, may be you can split the array into 4-5 parts and then put them into different methods. At the time of reading the array, call all the methods in a series. You may maintain a counter as well to know how many indexes you have parsed.
You can add another method to create space for your code for additional data space, you might have a method that is taking a large amount of data space. Try dividing your methods because I had the same issue and and fix it by creating another an additional method for the same data in my java Android code, The issue was gone after I did that.
This seems a bit like madness. Can you not initialize the array by reading the values from a text file, or some other data source?
this is due to all code in single methods solution :create more some small methods then this error will be gone
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 thecode
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.