

Method Size Limit in Java - pdeva1
http://eblog.chrononsystems.com/method-size-limit-in-java

======
adrianmsmith
This is a terrible limit. Code generation is necessary for all sorts of things
e.g. parsers. Having to hack in code to the code generation just to split
methods to get around this limit is ridiculous.

I had to literally abandon months of work on one project which was generating
simulation code to Java. I was generating millions of lines of code, so
splitting up the method would require a main method which would call all those
split methods, and then that method would get too long, etc. It all just
wasn't feasible, so now I just generate C.

<http://www.databasesandlife.com/java-method-64k-limit/>

~~~
ig1
Why not just have a binary tree of method calls with the leaf nodes containing
your actual code ? - that way you could easily have as many methods as you
wanted, and if it's auto-generated anyway it wouldn't be much extra work.

~~~
adrianmsmith
1) It's difficult to know how long a method will be when it's compiled.
Basically you have to compile it to find out. The 64k limit is on the
generated byte-code, not on the source.

2) Why bother? I mean generating C (in my case) was so much easier, a simpler
solution (not using a tree) is bound to have less bugs, be easier to maintain
etc.

I mean this is a fundamentally ridiculous limitation. One can work around it
with a large amount of effort, but it shouldn't be necessary.

------
Uchikoma
We had this problem some years ago with JSP which compiles all code into one
service() method.

~~~
nl
Yes, us too.

Often it is because of tag libraries that generate big try..catch..finally
blocks.

------
suprgeek
This is especially irritating considering the numerous other languages that
the JVM supports now. Oracle needs to fix this limitation along with bringing
in correct Generics support - not the way it is today.

