try statement 64k limit
Peter B. Kessler
Peter.Kessler at Sun.COM
Thu Sep 20 10:15:47 PDT 2007
Bartolomeo Nicolotti wrote:
> Hi,
>
> we have a big jsp that's translated in a .java that exceeds the 64k limit
> of the try statement with jdk 1.6. Is this limit also in openjdk 7? Is
> there a reason for this limit?
>
> Thanks
If by "the 64k limit" you mean that the total size of the bytecodes
for any method may not exceed 65535:
http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#9279
http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#88659
then that is a restriction of the class file format defined by the
Java virtual machine, and not a restriction imposed by JDK 1.6 or
OpenJDK 7. That limit might be raised in future specifications
for the Java virtual machine, but for now it's a constraint on all
Java virtual machine implementations.
The underlying reason is that many of the bytecode contain bytecode
offsets (e.g., for branches), and those are only 2 bytes long. Though
that's a kind of chicken-and-egg answer, since if those fields were
longer the restriction on the size of a method could be lifted.
The usual solution to your problem of compiling a big jsp into a
too big .java file is to find a better jsp compiler that produces
several smaller methods rather than a single large method.
... peter
More information about the hotspot-compiler-dev
mailing list