Archive

Posts Tagged ‘code too large’

Code too large for try statement ?

August 20th, 2009 CertPal 3 comments

If you didn’t already know it, the java language specification has limits on the size of a method. That limit is 65535 (number of bytes that the code occupies).

This so called limitation has never really bothered me. After practicing object oriented programming, modularization and good design principles you can only ask yourself ‘Who is crazy enough to write a method whose size is greater than 65535 !?’. But you know what ? It can happen. There are so many code gen tools out there and common libraries that will write code for you. Rules engines, JSP compilers, scripting/template engines will write dynamic code for you. If they do not write it withing the 65535 bytes limit, your code will not compile or will give a cryptic error and die.

Code suffering from this phenomenon will see this message – “Code too large to compile” or “Code too large for try statement“. So umm.. where did the try statement come from ?

Categories: java Tags: , ,