|
[ Index ] [ Individual Project ] [ Placement Presentation ] [ Timetable ]
[ Index ] [ Research ] [ Schedule ]
Eventually I want the tool to be able to upgrade the component on the fly, i.e. a running program can replace a certain package and then all future use of those classes run off the latest one. It isn't going to be a straight forward switch since the JVM loads the class into memory then what ever is on disk is irrelevant. Below is a short proof:
Code Listingsjavac -classpath . Test.java java -classpath . Test
I/O Trace:
d Old Version a Old Version d Old Version d Old Version
Switch over to the latest version of the component:
mv Component.java Component.java.old rm Component.class mv Component2.java Component.java javac -classpath . Component.java
First compile package one:
javac v1/com/milesbarr/test/Test.javaNo problems.
I/O Trace:
a Old Version b Old Version d Old Version f Old Version
Test.java:
import java.io.*;
public class Test {
public static void main (String args[]) {
Component c = new Component();
while (true) {
BufferedReader console = new BufferedReader (new InputStreamReader(System.in));
try {
int chosen = console.read();
}
catch (IOException e) {
e.printStackTrace();
}
c.print();
}
}
}
Component.java
public class Component {
public void print () {
System.out.println("Old Version");
}
}
Component2.java
public class Component {
public void print () {
System.out.println("New Version");
}
}