Java Tip #5 - Avoid 64KB method limit on JSP
Ok, this is hard to do on purpose with plain old java, but I've seen plenty of JSPs that when compiled had a method that exceeded the 64KB limit. Depending on the VM it may just barf and end with a hotspot error or it might give you some kind of useful message. I find it's just a hotspot error. Tomcat describes this problem in their release notes.
The simplest way to fix this is to break the page into parts so that each compiles separately using a jsp include. Avoiding big, monolithic JSPs is easy if you use Struts with Tiles. Of course, this shows how behind I am now since I'm not using one of the newer frameworks.
This seems to be less of a problem as container vendors have improved. They all generate different code, so it varied in our environment from Tomcat, SilverStream, and BEA. At one time or another, we had JSPs that exhibited the problem on one of the three platforms, but not the other two. I am happy to say we now target only one vendor, BEA.
Here is the blurb from section 4.10 of the Java Language Specification (JLS).
The simplest way to fix this is to break the page into parts so that each compiles separately using a jsp include. Avoiding big, monolithic JSPs is easy if you use Struts with Tiles. Of course, this shows how behind I am now since I'm not using one of the newer frameworks.
This seems to be less of a problem as container vendors have improved. They all generate different code, so it varied in our environment from Tomcat, SilverStream, and BEA. At one time or another, we had JSPs that exhibited the problem on one of the three platforms, but not the other two. I am happy to say we now target only one vendor, BEA.
Here is the blurb from section 4.10 of the Java Language Specification (JLS).
The amount of code per non-native, non-abstract method is limited to 65536 bytes by the sizes of the indices in the exception_table of the Code attribute (§4.7.3), in the LineNumberTable attribute (§4.7.8), and in the LocalVariableTable attribute (§4.7.9).Note that using the @include file directive does not solve the problem, since it just inlines the JSP. You need to use a jsp include or tiles or similar.
11 Comments:
I'm sure this is flamebait & don't know the answer to your question.
Nope, PHP doesn't have such a limit. Feel free to create 64k, 128k, or even 1M PHP files.
Yummy! 1MB of PHP!
The fact the 64K is the limit is a PLUS and not a minus imho. It forces separation of interface from logic.
stupid 64k limit should be fixed.
you should leave the seperation to the designers/developers instead of crashing when exceeding the limit.
Yaaaah 1MB of PHP!
Most of the PHP code I've seen: an unmaintainable mash exhibiting complete absense of reusability and complete denial of that the concept of separation of presentation and model code even exists.
Given this I guess needing 1MB for a PHP method isn't an unreasonable request...
.. however, needing more than 64K for a Java method means that, somewhere along the way, the Java developer probably missed some important software engineering concepts that enable the creation of quality, maintainable, flexible, extendable software.
".. however, needing more than 64K for a Java method means that, somewhere along the way, the Java developer probably missed some important software engineering concepts that enable the creation of quality, maintainable, flexible, extendable software."
you are right , but if you were not the one who developed it in a such a horrible way someone else did and you now need to add some code.
so you need to do alot more work than just adding your own code.
Koxpcu
Güvercin
Online Hack
Sinema Burda
proteinin açıklaması, protein açıklama, protein açıklamaları, protein acıklaması, regenerasyon nedir, proteinler açıklamaları, protein tozu yapılış tarifi, protein ile ilgili herşey
Thankks for writing
Post a Comment
<< Home