Tuesday, January 11, 2005

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 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.

15 Comments:

Blogger Behi said...

Do, say, Python and PHP also suffer from such a limit?

8:02 PM  
Blogger Billy Bob Bain said...

I'm sure this is flamebait & don't know the answer to your question.

10:14 PM  
Anonymous Anonymous said...

Nope, PHP doesn't have such a limit. Feel free to create 64k, 128k, or even 1M PHP files.

1:42 PM  
Blogger Patrick said...

Yummy! 1MB of PHP!

3:50 PM  
Blogger chris said...

The fact the 64K is the limit is a PLUS and not a minus imho. It forces separation of interface from logic.

6:21 AM  
Anonymous Anonymous said...

stupid 64k limit should be fixed.

you should leave the seperation to the designers/developers instead of crashing when exceeding the limit.

11:05 AM  
Blogger Sir Christopher said...

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.

7:00 PM  
Anonymous Anonymous said...

".. 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.

5:00 AM  
Anonymous Anonymous said...

Koxpcu 

Güvercin

10:52 AM  
Anonymous Anonymous said...

Aşçı Forum

Aşçı İş Arayanlar

Aşçı Arayanlar

Yerli Yemek Tarifleri

Aşçı Okulları

Dünya Global Mutfak

Profesyonel Yemek Malzemeleri



Profesyonel Sos çeşitleri


Tatlı Pasta Çeşitleri


Resturant Kurulumu


Yemek Üzerine İş yeri Kurulumu


Profesyonel Mutfak Malzemeleri

5:13 AM  
Blogger serkan said...

thanks for all information

bağcılar profilo servisi
bayrampaşa profilo servisi
bakırköy profilo servisi
avcılar ariston servisi
bağcılar ariston servisi
bahçelievler ariston servisi
bayrampaşa ariston servisi
beylikdüzü ariston servisi

4:36 PM  
Blogger turkey said...

yıldızname
vefk
isim falı
değerli taş
medyum

5:34 PM  
Anonymous Anonymous said...

Online Hack



Sinema Burda

4:21 PM  
Anonymous Anonymous said...

koxp



Güncel koxp



pvp koxp



metin2 koxp



euko koxp



knightonline hile hack

2:28 PM  
Anonymous protein tozu said...

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

9:51 AM  

Post a Comment

<< Home