Skip to content

Commit

Permalink
fix class unmapping in require()
Browse files Browse the repository at this point in the history
  • Loading branch information
ZZZank committed Aug 2, 2024
1 parent e49fd56 commit e03f3c3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/zzzank/probejs/plugin/Require.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] ar
return new RequireWrapper(null, Undefined.instance);
}
val parts = result.split("/", 2);
val path = new ClassPath(RemapperBridge.unmapClass(parts[1].replace('/', '.')));
val path = new ClassPath(parts[1].replace('/', '.'));
val pathJava = RemapperBridge.unmapClass(path.getClassPathJava());

NativeJavaClass loaded;
try {
loaded = manager.loadJavaClass(scope, new String[]{path.getClassPathJava()});
loaded = manager.loadJavaClass(scope, new String[]{pathJava});
} catch (Exception ignored) {
manager.type.console.warn(String.format("Class '%s' not loaded", path.getClassPathJava()));
manager.type.console.warn(String.format("Class '%s' not loaded", pathJava));
return new RequireWrapper(path, Undefined.instance);
}
return new RequireWrapper(path, loaded);
Expand Down

0 comments on commit e03f3c3

Please sign in to comment.