Fix ClassCast with decompiler's classloader
@@ -101,15 +101,14 @@ public class DecompilePanel extends JPanel {
srcText = addExtra(srcText);
name = srcText.substring(2, srcText.indexOf(";"));
}
- Class<?> clazz = null;
try {
- clazz = compiler.compile(name, srcText);
+ compiler.compile(name, srcText);
} catch (NullPointerException e) {
Recaf.INSTANCE.logging.error("Could not recompile, user attempted recompile from JRE process (not JDK).");
Recaf.INSTANCE.logging.error(new RuntimeException(Lang.get("window.compile.failjdk")));
return;
}
- DynamicClassLoader loader = ((DynamicClassLoader) clazz.getClassLoader());
+ DynamicClassLoader loader = Reflect.get(compiler, "classLoader");
Map<String, CompiledCode> code = Reflect.get(loader, "customCompiledCode");
if (code == null) {
Recaf.INSTANCE.logging.error("Could not recompile, could not fetch compiled code.");
@@ -138,6 +137,7 @@ public class DecompilePanel extends JPanel {
}
}
+
/**
* Really ugly hack for adding constructor to the extended class. Bypasses
* dependency on having all other methods in the class decompiling
