[jboss-dev-forums] [Javassist Development] - Probleme avec le Hotswap de Javassist

heavenkhn do-not-reply at jboss.com
Sun May 5 10:06:29 EDT 2013


heavenkhn [https://community.jboss.org/people/heavenkhn] created the discussion

"Probleme avec le Hotswap de Javassist"

To view the discussion, visit: https://community.jboss.org/message/815952#815952

--------------------------------------------------------------
import java.io.*;


import com.sun.jdi.connect.IllegalConnectorArgumentsException;


import javassist.util.HotSwapper;




public class Test {
    public static void main(String[] args) {
        HotSwapper hs = null;
                    try {
                              hs = new HotSwapper(8000);
                    } catch (IOException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                    } catch (IllegalConnectorArgumentsException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                    }
        new HelloWorld().print();


        File newfile = new File("bin
logging
HelloWorld.class");
        byte[] bytes = new byte[(int)newfile.length()];

        try {
                              new FileInputStream(newfile).read(bytes);
                    } catch (FileNotFoundException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                    } catch (IOException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                    }
        System.out.println("** reload a logging version");
        HelloWorld hl = new HelloWorld();
        String name = hl.getClass().getName();
        System.out.println(name);
        hs.reload(name , bytes);
        new HelloWorld().print();


        newfile = new File("HelloWorld.class");
        bytes = new byte[(int)newfile.length()];
        try {
                              new FileInputStream(newfile).read(bytes);
                    } catch (FileNotFoundException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                    } catch (IOException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                    }
        System.out.println("** reload the original version");


        hs.reload("HelloWorld", bytes);
        new HelloWorld().print();
    }
}




et voila ce que sa donne dans eclipse: 

Listening for transport dt_socket at address: 8000
hello world
** reload a logging version
HelloWorld
Exception in thread "HotSwap" java.lang.NoClassDefFoundError: class names do not match
          at com.sun.tools.jdi.VirtualMachineImpl.redefineClasses(VirtualMachineImpl.java:331)
          at javassist.util.HotSwapper.hotswap(HotSwapper.java:250)
          at javassist.util.HotSwapper$1.run(HotSwapper.java:224)
Exception in thread "main" java.lang.RuntimeException: failed to reload: HelloWorld
          at javassist.util.HotSwapper.reload2(HotSwapper.java:204)
          at javassist.util.HotSwapper.reload(HotSwapper.java:160)
          at Test.main(Test.java:38)


Sachant que Hello world a le code suivant : 


 public class HelloWorld {
    public void print() {
        System.out.println("hello world");
        this.x=2;
    }

    public int x;
}




Pourquoi ces exceptions sont-ils apparus ???

Merci.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/815952#815952]

Start a new discussion in Javassist Development at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2063]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20130505/7bfb7d62/attachment.html 


More information about the jboss-dev-forums mailing list