Skip to content

Openjdk Nashorn in toolchain cache keep downloaded to java 8 environment #531

@wysohn

Description

@wysohn

Description:
I might be wrong but want to hear the second opinion.

Here is the config file that uses setup-java: https://github.com/TriggerReactor/TriggerReactor/blob/0c75077f93a4804a525c941f4a6b16d9a82e2494/.github/workflows/build.yml#L71

When ScriptEngineManager is instantiated, it automatically looks for all the implementation that inherits ScriptEngineFactory, and when doing so, it uses ServiceLoader#load, which means, if the implementation of the ScriptEngineFactory exists in the classpath, it will be automatically detected by the ScriptEngineManager and loaded.

The problem is that because the one in the toolchaincache is a version compiled in Java 11, it throws UnsupportedClassVersionError as OpenJDK nashorn uses the same interface (ScriptEngineFactory).

Plus, it also doesn't make sense to add Openjdk Nashorn to classpath since Java 8 has the Nashorn embedded in it.

Piece of source code causing problem:
image

Stacktrace:
image

A possible fix is, if possible, not include OpenJDK Nashorn in toolchaincache if using Java version 8 or below

Task version:
v3

Platform:

  • Ubuntu
  • macOS
  • Windows

Could also be Windows, but never tested

Runner type:

  • Hosted
  • Self-hosted

Repro steps:
Simply instantiate ScriptEngineManager

Expected behavior:
NashornScriptEngineFactory from jdk8 should be used, not from OpenJDK nashorn

Actual behavior:
The OpenJDK nashorn from the toolchaincache is used

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions