Skip to content

Commit

Permalink
Fixed an error when initializing the NashornEngine of the plugin with…
Browse files Browse the repository at this point in the history
… lower versions of Java
  • Loading branch information
OmerBenGera committed Oct 2, 2022
1 parent 953b9f1 commit 40df514
Showing 1 changed file with 6 additions and 7 deletions.
Expand Up @@ -5,12 +5,6 @@

public class EnginesFactory {

private static final ReflectMethod<IScriptEngine> OPEN_JDK_NASHORN_ENGINE = new ReflectMethod<>(
"com.bgsoftware.superiorskyblock.core.engine.OpenJdkNashornEngine",
"getInstance",
new Class[0]
);

private static IScriptEngine defaultEngine;

private EnginesFactory() {
Expand All @@ -20,8 +14,13 @@ private EnginesFactory() {
public static IScriptEngine createDefaultEngine() {
if (defaultEngine == null) {
try {
ReflectMethod<IScriptEngine> nashornEngineGetInstance = new ReflectMethod<>(
"com.bgsoftware.superiorskyblock.core.engine.OpenJdkNashornEngine",
"getInstance",
new Class[0]
);
Class.forName("org.openjdk.nashorn.api.scripting.NashornScriptEngineFactory");
defaultEngine = OPEN_JDK_NASHORN_ENGINE.invoke(null);
defaultEngine = nashornEngineGetInstance.invoke(null);
} catch (Throwable error) {
defaultEngine = NashornEngine.getInstance();
}
Expand Down

0 comments on commit 40df514

Please sign in to comment.