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

Rhino is initialized - and therefore the lib necessary - even if Nashorn is available #93

Open
sdoeringNew opened this issue Sep 15, 2020 · 3 comments

Comments

@sdoeringNew
Copy link
Contributor

In a static initialization block in RegexECMA262Helper.java the available JavaScript engines are initialized. Javas Nashorn engine is pretty straight forward and can be used easily. That's the primary script engine which is always used if Java 8 - 14 is used.

However the backup engine Rhino is also initialized thus making it impossible to remove the Rhino lib from every application that uses the json-schema-core although it is unused during the whole runtime. 😞

Why not just initialize Rhino if Nashorn is not available?

@huggsboson
Copy link
Member

Happy to take a PR. Seems like it should be a pretty simple change to lazily init the Rhino objects.

@sdoeringNew
Copy link
Contributor Author

Yeah, sure. I'm familiar with the source code.

The only difficulty will be this awful code style - no offense ☮️. It gives me shivers.

sdoeringNew added a commit to sdoeringNew/json-schema-core that referenced this issue Sep 19, 2020
Additionally the Regex class was refactored now following the strategy pattern to prevent if / else on every method call. That refactoring also helped solving the issue.

Also add coverage to the class as the Rhino engine has not been unit-tested before if the build has been done with Java 8 - 14.
huggsboson pushed a commit that referenced this issue Sep 21, 2020
Additionally the Regex class was refactored now following the strategy pattern to prevent if / else on every method call. That refactoring also helped solving the issue.

Also add coverage to the class as the Rhino engine has not been unit-tested before if the build has been done with Java 8 - 14.
@bscSCORM
Copy link

@huggsboson are you still planning to release a version with #94 included?

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

3 participants