Reputation: 3720
I am developing a project where I am required to generate java code. I was doing some testing when I encountered a problem with 65535 bytes limit on the main method. My generated file looked something like that:
public class foo{
public static void main(String[] args){
//
//7000 lines later
//
}
}
I thought that I'm being clever by generating the file this way:
public class foo{
public static void bar(){
//
//7000 lines later
//
}
public static void main(String[] args){
bar();
}
}
But I found out that 65535 bytes limit applies to every method.
I want to know if 'buffering' instructions into multiple methods will solve my problem. Is there any restriction on how big can the java file be?
Upvotes: 1
Views: 417
Reputation: 5094
I suppose that restriction exists and you have reached it - as stated here.
Also, take a look at this discussion.
Upvotes: 1
Reputation: 3573
It's a known bug/feature request (official Java bug tracker).
Nevertheless, you should split it into different methods.
Upvotes: 1
Reputation: 533492
A file can be any size, but a method cannot compile to more than 65535 bytes long.
The only way to solve this is to
Upvotes: 9