Thursday, February 7, 2013

Maximum size of a method in Java


The maximum size of a method in java is 64k. If it exceeds, we'll get a compiler warning like "Code too large to compile" . It's not a bug but known limitation found in Java 1.3. It was requested as an enhancement on 12-Aug-1999 by the engineers of Sun Microsystem. The information was updated on 09-Oct-2012 but there is no news so far that the issue is fixed or not.

Have a look at this http://bugs.sun.com/view_bug.do?bug_id=4262078 

In well structured code, each method is a manageable length and is much smaller than this limit. Large pieces of data, to be loaded into arrays, can be read from a non Java files like a text or binary file.

But  the 64KB limit is only a problem for generated code especially  when initializing large arrays.

No comments:

Post a Comment