You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I ask InMemoryJavaCompiler to compile a new class with the same name as an existing class, the compile() method returns a reference to the existing class.
Minimal example across two files, both in the default package, compiled and loaded on the classpath:
Example.java:
public class Example {
}
MinimalExample.java:
import org.mdkt.compiler.InMemoryJavaCompiler;
public class MinimalExample {
public static void main(String args[]) throws Exception {
Class<?> oldClass = Example.class;
InMemoryJavaCompiler compiler = InMemoryJavaCompiler.newInstance();
Class<?> newClass = compiler.compile("Example", "public class Example {\n }\n");
if (oldClass.hashCode() == newClass.hashCode()) {
System.out.println("I have two copies of the old class.");
}
}
}
Expected behaviour: the class returned by compile should be the result of compiling the string passed to it.
I think this is a bug.
Thanks very much for providing this library! I am very keen to use it in Gin :-)
The text was updated successfully, but these errors were encountered:
If I ask InMemoryJavaCompiler to compile a new class with the same name as an existing class, the compile() method returns a reference to the existing class.
Minimal example across two files, both in the default package, compiled and loaded on the classpath:
Example.java:
MinimalExample.java:
Expected behaviour: the class returned by compile should be the result of compiling the string passed to it.
I think this is a bug.
Thanks very much for providing this library! I am very keen to use it in Gin :-)
The text was updated successfully, but these errors were encountered: