mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FIX] CommonHelper.newScriptEngine
This commit is contained in:
parent
cd5c78c413
commit
6127e92ce5
1 changed files with 13 additions and 3 deletions
|
@ -13,9 +13,16 @@
|
|||
|
||||
public final class CommonHelper {
|
||||
|
||||
public static final ScriptEngineManager scriptManager = new ScriptEngineManager();
|
||||
private static ScriptEngineFactory nashornFactory;
|
||||
|
||||
public static final ScriptEngineFactory nashornFactory = getEngineFactories(scriptManager);
|
||||
static {
|
||||
try {
|
||||
ScriptEngineManager scriptManager = new ScriptEngineManager();
|
||||
nashornFactory = getEngineFactories(scriptManager);
|
||||
} catch (Throwable e) {
|
||||
nashornFactory = null;
|
||||
}
|
||||
}
|
||||
|
||||
private CommonHelper() {
|
||||
}
|
||||
|
@ -48,7 +55,10 @@ public static String multiReplace(Pattern[] pattern, String from, String replace
|
|||
}
|
||||
|
||||
public static ScriptEngine newScriptEngine() {
|
||||
return Objects.requireNonNull(nashornFactory).getScriptEngine();
|
||||
if(nashornFactory == null) {
|
||||
throw new UnsupportedOperationException("ScriptEngine not supported");
|
||||
}
|
||||
return nashornFactory.getScriptEngine();
|
||||
}
|
||||
|
||||
public static Thread newThread(String name, boolean daemon, Runnable runnable) {
|
||||
|
|
Loading…
Reference in a new issue