From cc4522720881a9d70e6f541a8223d7934f1ae34d Mon Sep 17 00:00:00 2001 From: Konloch Date: Sun, 27 Jun 2021 16:37:34 -0700 Subject: [PATCH] Fixed Java Plugin Launching --- .../strategies/JavaPluginLaunchStrategy.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavaPluginLaunchStrategy.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavaPluginLaunchStrategy.java index 9dda32bb..17bf4009 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavaPluginLaunchStrategy.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavaPluginLaunchStrategy.java @@ -29,21 +29,28 @@ import the.bytecode.club.bytecodeviewer.plugin.PluginLaunchStrategy; * @author Bibl (don't ban me pls) * @created 1 Jun 2015 */ -public class JavaPluginLaunchStrategy implements PluginLaunchStrategy { - - private static final SimpleCompiler compiler = new SimpleCompiler(); +public class JavaPluginLaunchStrategy implements PluginLaunchStrategy +{ @Override - public Plugin run(File file) throws Throwable { + public Plugin run(File file) throws Throwable + { + SimpleCompiler compiler = new SimpleCompiler(); + + //compile the Java source compiler.cook(DiskReader.loadAsString(file.getAbsolutePath())); + //debug System.out.println(file.getName().substring(0, file.getName().length() - (".java".length()))); + + //get the class object from the compiler classloader Class clazz = Class.forName( file.getName().substring(0, file.getName().length() - ".java".length()), true, compiler.getClassLoader() ); + //create a new instance of the class return (Plugin) clazz.newInstance(); } } \ No newline at end of file