-
Type:
Bug
-
Resolution: Not an Issue
-
Priority:
P4
-
None
-
Affects Version/s: 9
-
Component/s: core-libs
-
generic
-
generic
NashornScriptEngineFactory finds the classloader of the user context that NashornScriptEngine is running on so that it can look up classes from the context.
The current implementation (see NashornScriptEngineFactory.getAppClassLoader()) looks at the frames on the stack at depth 3 and 4 and pick the first non-null user-defined class loader on the stack which is fragile. Change to the call stack may break this code but such regression is hard to catch reliably. Other script engine implementations may require similar capability.
The scripting API should be revisited how to provide script engine implementation to better integrate with Java. Possibly need to help passing the appropriate "context" to the script engine rather than relying the implementation to find it magically.
The current implementation (see NashornScriptEngineFactory.getAppClassLoader()) looks at the frames on the stack at depth 3 and 4 and pick the first non-null user-defined class loader on the stack which is fragile. Change to the call stack may break this code but such regression is hard to catch reliably. Other script engine implementations may require similar capability.
The scripting API should be revisited how to provide script engine implementation to better integrate with Java. Possibly need to help passing the appropriate "context" to the script engine rather than relying the implementation to find it magically.