Package javassist.util

Examples of javassist.util.HotSwapper

reload() first unload the Test class and load a new version of the Test class. classFile is a byte array containing the new contents of the class file for the Test class. The developers can repatedly call reload() on the same HotSwapper object so that they can reload a number of classes. @since 3.1


import java.io.*;
import javassist.util.HotSwapper;

public class Test {
    public static void main(String[] args) throws Exception {
        HotSwapper hs = new HotSwapper(8000);
        new HelloWorld().print();

        File newfile = new File("logging/HelloWorld.class");
        byte[] bytes = new byte[(int)newfile.length()];
        new FileInputStream(newfile).read(bytes);
        System.out.println("** reload a logging version");

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

        newfile = new File("HelloWorld.class");
        bytes = new byte[(int)newfile.length()];
        new FileInputStream(newfile).read(bytes);
        System.out.println("** reload the original version");

        hs.reload("HelloWorld", bytes);
        new HelloWorld().print();
    }
View Full Code Here

TOP

Related Classes of javassist.util.HotSwapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.