public static void main(String[] args) throws Exception {
Main main = new Main();
main.methodWhereExcutionIsHaltNClassIsUpdated();
}
private void methodWhereExcutionIsHaltNClassIsUpdated() throws Exception {
Scanner scan = new Scanner(System.in);
System.out.print("Enter a: ");
// before running the next line we update the class file to print "a:" to "AMODIFED"
// but still it prints the "a:"
Integer a = Integer.parseInt(scan.next());
System.out.print("a: "+ a);
}
}
HOTSWAP AGENT: 21:57:45.161 INFO (org.hotswap.agent.HotswapAgent) - Loading Hotswap agent {1.1.0-SNAPSHOT} - unlimited runtime class redefinition.
HOTSWAP AGENT: 21:57:45.725 ERROR (org.hotswap.agent.config.PluginRegistry) - Error in plugin initial processing for plugin package 'org.hotswap.agent.plugin'
java.lang.ClassNotFoundException: org/hotswap/agent/plugin/hotswapper/HotswapperPlugin
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at org.hotswap.agent.config.PluginRegistry.scanPlugins(PluginRegistry.java:89)
at org.hotswap.agent.config.PluginManager.init(PluginManager.java:125)
at org.hotswap.agent.HotswapAgent.premain(HotswapAgent.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:382)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:397)
Invalid layout of java.lang.Thread at name
Error occurred during initialization of VM
Invalid layout of preloaded class: use -XX:+TraceClassLoading to see the origin of the problem class
public class JavaEcho {
public static void main(String[] args) {
String input = "";
while(!"quit".equals(input)) {
System.out.print("Say : ");
Scanner scan= new Scanner(System.in);
input = scan.nextLine();
System.out.println("Echo: " + input);
}
}
}
hotswap-agent.propeties
in the same directory with the following properties:
extraClasspath=compile/JavaEcho.class
autoHotswap=true
java -XXaltjvm=dcevm -javaagent:/home/zakaria1/Downloads/hotswap-agent-1.0.jar -cp . JavaEcho