-
Notifications
You must be signed in to change notification settings - Fork 820
Description
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:

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
