JDK-8063100 : Unnecessary invalidation of global constants in Context.setGlobal
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: javax.script
  • Affected Version: 9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2014-11-06
  • Updated: 2020-04-20
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.
Related Reports
Blocks :  
Context.setGlobal invokes GlobalConstants.invalidateAll(). This is unnecessary as running code with that Global will still only create linkage in code compiled by Global's creating Context.

(As a matter of fact, Context.setGlobal is probably misleading as it's not associating a Global with a Context. It's associating a Global with the current thread.)

Removing the call to invalidateAll() will unfortunately reveal incorrect behavior when a single ScriptEngine's eval() is invoked with different global bindings. Specifically, unless JDK-8062937 is comprehensively fixed for all possible mutation paths, ScriptEngineTest:checkPropertyReadPermissions fails as it incorrectly does a constant-binding of variable "name" which is changed through Java API ScriptEngine.put() between eval() invocations.