@@ -0,0 +1,1385 @@
+package com.bytebeats.codelab.javassist;%0A%0Aimport javassist.*;%0A%0A/**%0A * $%7BDESCRIPTION%7D%0A *%0A * @author Ricky Fung%0A * @date 2017-02-16 18:07%0A */%0Apublic class JavassistDemo2 %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        try %7B%0A            testAddMethod();%0A        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A    public static void testAddMethod() throws Exception %7B%0A        ClassPool pool = ClassPool.getDefault();%0A        pool.importPackage(%22%22);%0A%0A        CtClass point = pool.get(%22Point%22);%0A        CtMethod m = CtNewMethod.make(%0A                %22public int xmove(int dx) %7B x += dx; %7D%22,%0A                point);%0A        point.addMethod(m);%0A%0A    %7D%0A%0A    public static void testAddField() throws Exception %7B%0A        CtClass point = ClassPool.getDefault().get(%22Point%22);%0A        CtField x = new CtField(CtClass.intType, %22x%22, point);%0A        point.addField(x);%0A%0A        CtField y = new CtField(CtClass.intType, %22y%22, point);%0A        point.addField(y, %220%22);    // initial value is 0.%0A%0A        CtField f = CtField.make(%22public int z = 0;%22, point);%0A        point.addField(f);%0A    %7D%0A%0A    public static void testImport() throws Exception %7B%0A%0A        ClassPool pool = ClassPool.getDefault();%0A        pool.importPackage(%22java.awt%22);%0A        CtClass cc = pool.makeClass(%22Test%22);%0A        CtField f = CtField.make(%22public Point p;%22, cc);%0A        cc.addField(f);%0A    %7D%0A%7D%0A

update code