diff --git a/pom.xml b/pom.xml
index 907e8b2..0775308 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
pw.yumc
MiaoScript
- 0.9.6
+ 0.9.7
502647092
@@ -54,6 +54,7 @@
DEV
+ §620-12-07 §afix: 修复 Windows 环境 重载异常;
§620-11-19 §afeat: 新增 JavaScriptTask 类;
§620-11-11 §afeat: 新增 package 版本锁定逻辑;
§620-09-21 §afeat: 完善 upgrade 逻辑;
diff --git a/src/main/java/pw/yumc/MiaoScript/ScriptEngine.java b/src/main/java/pw/yumc/MiaoScript/ScriptEngine.java
index e604b06..8a55185 100644
--- a/src/main/java/pw/yumc/MiaoScript/ScriptEngine.java
+++ b/src/main/java/pw/yumc/MiaoScript/ScriptEngine.java
@@ -13,12 +13,14 @@ import java.nio.file.Paths;
* @author 喵♂呜 Created on 2017/10/25 21:01.
*/
public class ScriptEngine {
- private final String root;
+ private final ClassLoader loader;
private final Object logger;
+ private final String root;
private final Base base;
private MiaoScriptEngine engine;
public ScriptEngine(String root, Object logger, Object instance) {
+ this.loader = Thread.currentThread().getContextClassLoader();
this.root = root;
this.logger = logger;
this.base = new Base(instance);
@@ -38,6 +40,8 @@ public class ScriptEngine {
@SneakyThrows
public void enableEngine() {
createEngine();
+ ClassLoader originLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(this.loader);
Path bios = Paths.get(root, "bios.js");
// 如果存在自定义bios就加载自定义的
if (Files.exists(bios)) {
@@ -46,6 +50,7 @@ public class ScriptEngine {
this.engine.eval("load('classpath:bios.js')");
}
engine.invokeFunction("boot", root, logger);
+ Thread.currentThread().setContextClassLoader(originLoader);
}
@SneakyThrows