• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

code too large for try statement

 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting error on UNIX env "code too large for try statement" in jdk 1.5. Though it compiles in eclipse jdk 1.6. Would anyone help?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow. That must be some bad code. Is it a JSP?
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. its not a jsp. It simply java code having 38K lines.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to break the code inside that try block up into separate methods, then have the (now much shorter) code inside the try block call those methods.
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand it...But what is the reason i am able to compile it on eclipse jdk 1.5
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The real limitation(s) are some dimensions in the class file format specification: there are a number of short integers used as dimensions that limit the size of a method or of a jump to 32,767 bytes. Compilers have a little leeway on how they implement things, and a smarter compiler might generate tighter code such that a large block of code might barely fit using one compiler, but not fit when using another.

So is this hand-written code, or machine-generated code? (That's what the JSP question was getting at.) Writing this much code by hand in a single method is hard to imagine, but you can easily imagine a FORTRAN translator that does it, for example, or a complex machine-generated parser.
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Patricia Samuel wrote:No. its not a jsp. It simply java code having 38K lines.



I have been in computing for over 45 years and I have never ever seen a single method anything like 38K lines long. The longest human generated single method I have seen is about 2.5K lines (FORTRAN) and the longest computer generated single method was about 8K lines (CSMP compiled to FORTRAN).

I would love to know what motivates a design requiring this horrendous method.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One place I consulted at had a 30k+ line file that was a giant set of nested if-elses, maintained by hand (but not in Eclipse, because it made Eclipse crash).

But yes, you'll need to break it up into smaller methods. Preferably smaller classes and files, too. We had the same issue on a Solaris box, but that was with a JSP that had been built with static includes :/
 
Marshal
Posts: 80447
451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have look at the JVM specifications. You find that the largest method permissible is very slightly less than 64kB in bytecode, so your long block is presumably exceeding 64kB.
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so many speculations!!!

Folks, its a talend generted code and try block has 7000 lines of code. it works perfectly in eclipse. I see no compilation error. But when i use my build.xml on unix environment it throws code too large for try statement. Any help!!!

Patricia
 
Campbell Ritchie
Marshal
Posts: 80447
451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Copy the block into a standalone class and compile that from the command line. See what happens.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Patricia Samuel wrote:so many speculations!!!

Folks, its a talend generted code and try block has 7000 lines of code. it works perfectly in eclipse. I see no compilation error. But when i use my build.xml on unix environment it throws code too large for try statement. Any help!!!

Patricia


It's a different JVM. It will have different limitations. The error message is telling you precisely what the issue is; you'll need to find a way around it.
 
Campbell Ritchie
Marshal
Posts: 80447
451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote: . . . It's a different JVM. It will have different limitations. . . .

Oh, I'd never heard of talend before. Didn't know it is a different VM.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No no, OP said code was generated by "talend". But it's running on a different JVM than the one he was testing on.

Personally I wouldn't think 7000 lines in a try block would be too many (from a technical standpoint), but apparently I'd wrong when I think that.
 
Campbell Ritchie
Marshal
Posts: 80447
451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for clearing up my misunderstanding.


But the bit about 64kB should apply unchanged to all JVMs? 7000 lines of code will be ≫64kB, but it will presumably be much less when converted to bytecode. But 38000+ lines??
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
might this help?

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How?
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:How?



If the Eclipse compiler manages to create valid class files from the code, but Sun's doesn't, then this tool will let you use the Eclipse compiler to build outside of Eclipse. Sounds like a good idea actually, since apparently she has no control over the code itself.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:But the bit about 64kB should apply unchanged to all JVMs? 7000 lines of code will be ≫64kB, but it will presumably be much less when converted to bytecode. But 38000+ lines??


My example, turns out, has multiple methods in it; the file itself is just over 30k lines, but there are more methods in it than I thought.

Not sure about the JSP issue we had; it was awhile ago.
 
Campbell Ritchie
Marshal
Posts: 80447
451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the file is 30000 lines long, but contains several methods, then it is likely each method will be of the permissible size.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, that's what I'm saying. I had remembered there being only a few methods, but I was mistaken. They "refactored". Sort of.
 
Campbell Ritchie
Marshal
Posts: 80447
451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, refactoring takes all the fun out of it
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic