Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant pool has grown past JVM limit of 0xFFFF #218

Open
WZRPW opened this issue Apr 8, 2024 · 3 comments
Open

Constant pool has grown past JVM limit of 0xFFFF #218

WZRPW opened this issue Apr 8, 2024 · 3 comments

Comments

@WZRPW
Copy link

WZRPW commented Apr 8, 2024

I use Janino to compile a generated Java code which has a large number of lines of code,

##################################
ClassBodyEvaluator evaluator = new ClassBodyEvaluator();
.....
evaluator.cook(codeFile, codeBody);
##################################

I got this compilation error at runtime:
Caused by: org.codehaus.commons.compiler.InternalCompilerException: Compiling “myTestCode” in File '/tmp/myTestCode.java', Line 1, Column 1: File '/tmp/myTestCode.java', Line 8559, Column 265: Compiling "myTestCode(param1, param2, param3, param4)”: File '/tmp/myTestCode.java', Line 8653, Column 5: org.codehaus.commons.compiler.InternalCompilerException: File '/tmp/myTestCode.java', Line 8653, Column 5: Compiling "init()": Constant pool for class myTestCode has grown past JVM limit of 0xFFFF

Could you help me understand what this exception means?
Thanks,

@WZRPW
Copy link
Author

WZRPW commented Apr 8, 2024

Does this mean the myTestCode file is too large or the init(), a function, has too many lines of code?

@WZRPW
Copy link
Author

WZRPW commented Apr 8, 2024

OK. I find a stackoverflow thread which gives a well written intro about Java constant pool.

@WZRPW WZRPW closed this as completed Apr 8, 2024
@aunkrig
Copy link
Member

aunkrig commented Apr 9, 2024

In case you're wondering what fills your constant pool, you could set a breakpoint where the exception is thrown and inspect the constant pool.

There are many different constant pool entry types (not only string literals), and you might be able to develop strategies to change your code generation such that you avoid sonstant pool bloat.

@aunkrig aunkrig reopened this Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants