This week's book giveaway is in the Design and Architecture forum.
We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line!
See this thread for details.
  • 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Size of .java file affects compiling.

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a .java file whose size is more than 1 GB. Please dont curse me for this as this file is automatically generated by the existing system based on some inputs.

As of now this 1 GB java file is giving errors while compiling. It is not able to compile.

I want to ask does java has such restrictions. Is there a way to compile such file. Other way around is change the code which generates 1GB file.

If you guys have anything related to this please let me know.

regards
khushal
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Offhand I don't remember what if any intrinsic limits there may be in the process. But I'm not surprised that a 1 GB file causes problems. Perhaps you could tell us what is the text of the first few compile errors you get? That may well give important clues as to what, exactly, the problem is.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can have problems with the JVM that runs javac running out of heap. You can fix these by passing arguments to that JVM using the -J option of javac.

For example, -J-Xms48m sets the initial heap to 48 megabytes.
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The compiler will not accept any sourcefile that has more than 64K lines in any single method.
I'm pretty certain there are similar restrictions to the number of methods per class, data members per class, and classes per file.

Any class that big is a monster that needs serious refactoring anyway
Or if it's generated, kill the generator.
 
khushal malik
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help. I will get more details on it. Killing the generator is a nice idea
 
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

Originally posted by Jeroen T Wenting:
The compiler will not accept any sourcefile that has more than 64K lines in any single method.



Another limit is 64k bytes of emitted code in a method; sometimes less, as a jump instruction takes a 16-bit signed offset as an argument.

A 1GB emitted file is extremely impressive (or inauspicious, depending on how you look at it.)
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's definitely something extreme, anyway.
 
Marshal
Posts: 28293
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeroen T Wenting:
Any class that big is a monster that needs serious refactoring anyway
Or if it's generated, kill the generator.

Or combine the two ideas and refactor the generator.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am curious where is the bulk in this generated Java source? If it is in String constants perhaps they can be stored elsewhere.

In any case, please let us know the solution you come up with.

Bill
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm with you Bill, I'd love to know how you end up with a 1 GB source file. I can't think of a project that I've worked on that had anywhere near 1 GB of source total.

Just for reference I downloaded "Moby Dick" by Herman Melville from Project Gutenberg, unzipped it is 1.15 MB.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I faced a similar problem in my project. We use one propertory IDE for development which generates the java code. I found two generated files of size 5 MB. And these files failed to compile because of the large size of methods. Then I manually edited the file and replaced the large methods with a set of small methods and written some logic to integrate these small methods. So that from out side it appeared the same but internally it calls these small methods.
 
Yeah, but how did the squirrel get in there? Was it because of the tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic