-
Notifications
You must be signed in to change notification settings - Fork 82
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
Experiment standalone nashorn #111
Conversation
try { | ||
tmp_JDK_NASHORN_ScriptObjectMirror_CLASS = Class.forName("jdk.nashorn.api.scripting.ScriptObjectMirror"); | ||
} catch (ClassNotFoundException e) { | ||
System.out.println("JDK Nashorn not found"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume in the final version we wouldn't want to log out here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, like I wrote in the description, this is a basis for discussion and must not be merged as is.
I think there should be somewhere a log statement indicating which version of Nashorn is used and why, but that should probably be at debug level.
STANDALONE_NASHORN_NashornScriptEngineFactory_CLASS = tmp_STANDALONE_NASHORN_NashornScriptEngineFactory_CLASS; | ||
STANDALONE_NASHORN_ClassFilter_CLASS = tmp_STANDALONE_NASHORN_ClassFilter_CLASS; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better to manage this in a centralised place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most certainly, that should move to a class like NashornDetection, that would do the detection and debug logs about what is going on.
I think key would be to retain compatibility with 1.8. I think we can run it against different versions as part of the travis build: https://github.com/javadelight/delight-nashorn-sandbox/blob/master/.travis.yml Also we need to be careful to try to make it as simple as possible to understand, since there is a bit of complexity involved here. |
I agree that we must not break existing users. |
Will need to add back a run of the tests on JDK 8 too.
STANDALONE_NASHORN_NashornScriptEngineFactory_CLASS = null; | ||
STANDALONE_NASHORN_ClassFilter_CLASS = null; | ||
} | ||
// TODO add a report of what was detected and what will be used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I think so, as you said maybe a debug level log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I had a sleepless night so I worked on this a bit, but it's not finished yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One step at a time, and take care!
} | ||
|
||
public static SandboxClassFilter createSandboxClassFilter() { | ||
// TODO allow to force one impl? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm interesting question - probably that would be a property on the Sandbox?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of 2 properties:
- prefer JDK or standalone nashorn, in case both are present
- force the use of one of those, throw an exception if not available
Also, and maybe that starts to be overkill, we could do:
- a property on the sandbox to have fine grained control, that could be useful for people that want to do it in tests
- a System property, so users can set the properties on the JVM with something like
-Ddelight-nashorn-sandbox.nashorn.provider=standalone
The sandbox property would have precedence, fallback to the System property, then fallback to the auto detection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I am thinking given the kind of low level nature of this, a system property maybe sufficient?
So default to standalone if present, unless there is a system property to overwrite it?
I like it, great work! So now all the tests would run against 11 and the non-JDK Nashorn version, correct? But since we still have the target Only thing missing would be then to run the tests against the JDK Nashorn in 1.8 as well. But not sure if we can do that. But maybe we also don't necessarily need to. I guess there is an argument to be made that we would want to run the test only against the most recent Nashorn version? |
Yes, running with JDK 11 with target 1.8 will still produce bytecode that will run on JDK 8. I'll try to have a build testing several combinations:
As Travis-ci is a bit out of favor these days, would it be a possibility to migrate to Github Actions? |
I don't mind migrating to GitHub actions at all - will also have to find a new way to push this to Maven central since Bintray is shutting down 😢 |
Hello. I was wondering when is it planned to merge these changes into the master branch? |
Due to the use of both JDK (removed from 15) and Standalone Nashorn (compiled to 11), we must build on JDK 11 with source and target 1.8. Then we can run the tests on JDK 8 and 15 with maven verify. We must not clean or change the sources in between the build on JDK 11 and the tests on other JDKs otherwise, Maven will rebuild the module and will fail.
Hello, I just pushed a version that seems to work on JDK 8, 11 and 15.
|
Oups, that was meant to be a draft for discussion about #109, please treat it as the basis for discussion and not a serious PR.
What I think needs more effort:
1- build on 11 targeting 8
2- raise the minimal version to 11 (probably not the best solution)
3- split in another module so the core builds on 8 and the module for standalone nashorn builds on 11