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

Error when compiling exported Java code using javac: Too many constants #298

Open
kijz opened this issue Aug 21, 2020 · 2 comments
Open

Comments

@kijz
Copy link

kijz commented Aug 21, 2020

Hi!

I have problems when compiling the generated Java Code from m2cgen.
I am using an XGBClassifier with n_estimators = 400.
The generated code is ~360k lines long, which is around 17MB.

Unfortunately, this code does not compile with javac as i get this error:

Model.java:1: error: too many constants
public class Model {
       ^
1 error

Using the approach suggested in #297, i have managed to split the score function into subroutines, which unfortunately does not fix my problem.

Is there any workaround for this type of error?
Manually adjusting the file is not really an option since i am planning to create a large number of models and compare them

@izeigerman
Copy link
Member

izeigerman commented Aug 24, 2020

Hey @fkajzer! Sorry you run into this issue.

Unlike in the #297 issue, splitting code into subroutines doesn't help in your case, because the too many constants error is a constraint of the compiled Java class and not just a single method.

Unfortunately m2cgen doesn't support splitting code into multiple classes / modules today.

The only workaround that I can suggest for now is to reduce the number or size of your estimators. Though I realize that this likely doesn't work for you.

UPD More context can be found here: https://stackoverflow.com/questions/11437905/java-too-many-constants-jvm-error

@Aulust
Copy link
Contributor

Aulust commented Sep 4, 2020

Hi, I've encountered the same problem, suggested fix is in #306

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants