I'm writing a custom loading system for my mod. The loading system will load classes from a zip that have a specified annotation, and then call a load method. The problem is java cannot find the method in the class that has it, in which I've done some searching, and found that you need an instance of the class to execute the method.
How can I get an instance of the class in the zip file in order to invoke the method?
This code is supposed to load and execute the method from within the development environment, but the actual loader does a similar thing. Upon load and discovery of the class, it throws a NoSuchMethodException, saying that it cannot find the method in java.lang.Class.
Class clazz = classLoader.loadClass("net.minecraft.src.MyClass");
b = false;
System.out.println(header + "Loaded Plugin with ID: " + ((MyAnnotation)clazz.getAnnotation(MyAnnotation.class)).pluginID());
System.out.println(header + "Class loading will be disabled in a future update!");
Method method = clazz.getDeclaredMethod("preLoad", PluginPreLoadEvent.class);
method.invoke(clazz.getClass(), new PluginPreLoadEvent(Minecraft.getMinecraft(), MyClass.currentSide));
System.out.println(MyClass.header + "PreLoad initialized.");