This week's book giveaway is in the Flex forum.
We're giving away four copies of Flex 4 in Action and have Tariq Ahmed, Dan Orlando, John C. Bland II & Joel Hooks on-line!
See this thread for details.
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Win a copy of Flex 4 in Action this week in the Flex forum!
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Java in General
 
RSS feed
 
New topic
Author

How to fix java method size limit 65k

shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Messages: 104

In my application, we are generating java code in which method size is increasing more than 65k. I am trying to divide it in sub routines, but not very successful in my attempt.
Looking here for suggestions/code to overcome the issue, or is there a way to compile method with size more than 65k.

SCJP 1.5(97%) http://shivendra-tripathi.blogspot.com
Campbell Ritchie
Bartender

Joined: Oct 13, 2005
Messages: 14984

That is the compiled size of the method, not the size of the code. BTW: 65536 is 64k not 65. More details here in the JVM specification.

But why on earth would anybody want such large methods in the first place?
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Messages: 104

Thanks for response and correction. The method is getting generated to create mapping for xml elements , and xml file feeded is quite large. We use recursion to take care of multi level parent child, siblings relationship. Now any thoughts to overcome this issue?

SCJP 1.5(97%) http://shivendra-tripathi.blogspot.com
Henry Wong
author
Bartender

Joined: Sep 28, 2004
Messages: 10007


This issue has been on Sun enhancement request list, since... well, for as long as I can remember. I think that it is safe to not depend on Sun to fix this limitation.

Your only work-around is to modify your code generator, to generate code using many methods, instead of one big method.

Henry

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
David Newton
Author
Bartender

Joined: Sep 29, 2008
Messages: 6843

+1; you'll need to change the code generator.

Consultant/Trainer | Polyglottal Developer | Struts Committer/PMC | Struts 2 Web Application Development
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Messages: 104

Thanks for your time guys. I did fix it by breaking the code into sub routines. Just wondering, Does java has some limit for class size as well ?

SCJP 1.5(97%) http://shivendra-tripathi.blogspot.com
Ulf Dittmer
Sheriff

Joined: Mar 22, 2005
Messages: 26770

The first entry under the link Campbell posted says "yes, there is a limit".

Java web chartsImageJ PluginsSpecification URLsJava FAQs
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Java in General
 
RSS feed
 
New topic
replay challenge