"Code too large" compilation error in Java
A single method in a Java class may be at most 64KB of bytecode.
But you should clean this up!
Use .properties
file to store this data, and load it via java.util.Properties
You can do this by placing the .properties
file on your classpath, and use:
Properties properties = new Properties();InputStream inputStream = getClass().getResourceAsStream("yourfile.properties");properties.load(inputStream);
There is a 64K byte-code size limit on a method
Having said that, I have to agree w/Richard; why do you need a method that large? Given the example in the OP, a properties file should suffice ... or even a database if required.
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.