Forums Register Login

Size of .java file affects compiling.

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Thanks for the help. I will get more details on it. Killing the generator is a nice idea
+Pie Number of slices to send: Send
 

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.)
+Pie Number of slices to send: Send
It's definitely something extreme, anyway.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1165 times.
Similar Threads
Searching a large text file...
Page Count in PDF document
download size limit in windows
Hot deploy of Java Classes on Weblogic 9.1
sending large files through webservice
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:07:38.