A
Aryeh M. Friedman
ClassLoader does not update class on recompile:
Script started on Tue Oct 2 01:45:20 200
{
public static void main(String[] args)
throws Throwable
{
while(true) {
ClassLoader loader=ClassLoader.getSystemClassLoader();
Class klass=loader.loadClass("MyClass");
MyClass mc=(MyClass) klass.newInstance();
System.out.println("hit any key to reload/rerun MyClass");
System.in.read();
}
}
}
{
public MyClass()
{
System.out.println("not hi there");
}
}
hit any key to reload/rerun MyClass
not hi there
hit any key to reload/rerun MyClass
^Z
Suspended
{
public MyClass()
{
System.out.println("foo on you");
}
}
not hi there
hit any key to reload/rerun MyClass
^C
Script started on Tue Oct 2 01:45:20 200
public class Maincat Main.java
{
public static void main(String[] args)
throws Throwable
{
while(true) {
ClassLoader loader=ClassLoader.getSystemClassLoader();
Class klass=loader.loadClass("MyClass");
MyClass mc=(MyClass) klass.newInstance();
System.out.println("hit any key to reload/rerun MyClass");
System.in.read();
}
}
}
public class MyClasscat MyClass.java
{
public MyClass()
{
System.out.println("not hi there");
}
}
not hi therejavac *.java
java Main
hit any key to reload/rerun MyClass
not hi there
hit any key to reload/rerun MyClass
^Z
Suspended
public class MyClasscat foo
{
public MyClass()
{
System.out.println("foo on you");
}
}
java Mainmv foo MyClass.java
javac MyClass.java
fg
not hi there
hit any key to reload/rerun MyClass
^C
Script done on Tue Oct 2 01:47:02 200exit