HI! ALL...
I am facing a problem related to dynamic loading of class .
The class below (Continuous.class) has got a reference to class Afile
Which is being loaded dynamically through Class.forName() but after the first invocation to loadNewVersion() when Thread.sleep(20000) is called i change the Afile.java mean while but that change is not getting reflected in the second invocation during the single run of the program.
Continuous.java
public class Continuous
{
Afile afile=null;
public void loadNewVersion()
{
try{
afile=(Afile)Class.forName("Afile").newInstance();
System.out.println("new instance created");
}catch(ClassNotFoundException cnfe)
{
System.out.println("Afile not found");
}
catch(InstantiationException ie)
{
System.out.println("instantation exception ");
}
catch(IllegalAccessException iae)
{
System.out.println("illegal access exception ");
}
catch(MalformedURLException mue)
{
System.out.println("malformed exception ");
}
}
public static void main(
String args[])
{
System.out.println("Inside main method");
Continuous obj=new Continuous();
obj.test();
try
{
Thread.sleep(20000);
}catch(InterruptedException iex)
{
System.out.println("Thred Interrupted");
}
obj.test();
}
public void
test()
{
loadNewVersion();
System.out.println(afile.getTitle());
}
}
Afile.java
public class Afile
{
public String title;
public String getTitle()
{
return "this is a old one newwe ";
}
}