Code too large for try statement ?
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 ?
Jave Server Page (JSP) templates sometimes follow a syntax that resembles this
# Include Header
If you end up writing complex logic in your JSP and include (static includes) other files to partake in the final output, you might end up breaking your page. The error is not necessarily well defined. The same JSP page which might compile with version 8 of weblogic will fail in version 10 or might compile in tomcat and fail in JBOSS. This is because each container writes code within the JSP in its own way.
The try catch may not even be introduced by you. Your container may introduce the try catch (for whatever internal reasons) for code written in the JSP. This problem is famous for creeping up when you move from one container to another or shift between container versions. The error occurs either when you request for a JSP page the first time (and the container tries to compile it) or when you try to pre compile the JSP for performance reasons.
Help your container modularize the code. Try splitting the JSP into several chunks and make dynamic includes instead of static ones. Dynamic includes (jsp:include against %@include) will compile the JSP and then stream the output instead of trying to include all the code into one big method or try catch block.
You can read up on the limitation here
Look for this text
The value of the code_length item must be less than 65536