JDK-8135262 : Sanitize CodeInstaller and Compiler API
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2015-09-09
  • Updated: 2016-01-14
  • Resolved: 2015-09-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
8u72Fixed 9 b82Fixed
Nashorn's CodeInstaller API has few problems:
- the type parameter <T> is unnecessary, as we only have one specialization for <ScriptEnvironment>
- accordingly, "T getOwner()" should be changed to "ScriptEnvironment getScriptEnvironment()". Better yet, "Context getContext()"

Nashorn's Compiler constructors are horrendous and it's not entirely clear which one is for what purpose. This could be somewhat remedied by:
- replacing them with static factory methods with descriptive names, and
- when CodeInstaller is passed, neither Context, ScriptEnvironment, nor ErrorManager need to be passed as they can all be reached through the CodeInstaller if we have the above proposed CodeInstaller.getContext(). In some cases (eval implementation), ErrorManager should still be passed as something other than Context.errMan is used.