package javassist.bytecode; //import javassist.bytecode.*; import javassist.*; import java.util.*; import java.io.*; public class LocalVariableTypeAttributeTest{ //should kill IHD1 /* public String test1(){ ConstPool cp = new ConstPool("assignment10.Point2"); // ExceptionTable et = new ExceptionTable(cp); // et.add(0,1,2,0,0); // et.add(1,1,2,0,2); // byte[] code = "dd".getBytes(); // CodeAttribute ca = new CodeAttribute(cp, 5, 3, code, et); // Bytecode bc = new Bytecode(cp, 1, 0); // bc.addIconst(3); // bc.addReturn(CtClass.intType); // CodeAttribute ca = bc.toCodeAttribute(); // CodeIterator.Pointers cip = new CodeIterator.Pointers(0, 1, 2, et, ca); //Handler hdl = new Handler(et, 0, ca.iterator(), CtClass.intType, null); //System.out.println(et.catchType(1)); //hdl.replace0(0, bc, 2); //ExprEditor ee = new ExprEditor(); //hdl.runEditor(ee, ca.iterator()); // et.remove(0); //System.out.println(cip.etable.size()); LocalVariableTypeAttribute lvta = new LocalVariableTypeAttribute(cp); return lvta.tag; } //kill IHI1 public int test2(){ ConstPool cp = new ConstPool("assignment10.Point2"); LocalVariableTypeAttribute lvta = new LocalVariableTypeAttribute(cp); return lvta.info.length; } //IOD public String test3(){ ConstPool cp = new ConstPool("assignment10.Point2"); LocalVariableTypeAttribute lvta = new LocalVariableTypeAttribute(cp); return lvta.renameEntry("Lx<;", "x", "x1"); } public String test4(){ ConstPool cp = new ConstPool("assignment10.Point2"); LocalVariableTypeAttribute lvta = new LocalVariableTypeAttribute(cp); HashMap hm = new HashMap(); hm.put("x", "x1"); return lvta.renameEntry("Lx<;",hm); }*/ //IOD_3 is equivalent public int test5() throws Exception{ BufferedInputStream fin = new BufferedInputStream(new FileInputStream("c:\\mujava\\classes\\javassist\\bytecode\\LocalVariableAttribute.class")); ClassFile cf = new ClassFile(new DataInputStream(fin)); ConstPool cp = cf.getConstPool(); LocalVariableTypeAttribute lvta = new LocalVariableTypeAttribute(cp); lvta.renameClass("x","x1"); return lvta.info.length; } //IOR_1, 2 CANNOT BE KILLED, MAY BE NOT EQUIVALENT /* public static void main (String[] args) throws Exception{ BufferedInputStream fin = new BufferedInputStream(new FileInputStream("c:\\mujava\\testset\\javassist\\bytecode\\Point2.class")); ClassFile cf = new ClassFile(new DataInputStream(fin)); ConstPool cp = cf.getConstPool(); LocalVariableTypeAttribute lvta = new LocalVariableTypeAttribute(cp); System.out.println("info: " + lvta.info.length); System.out.println("table length: " + ByteArray.readU16bit(lvta.info, 0)); lvta.renameClass("x","x1"); System.out.println(lvta.tag); //System.out.println(lva.renameEntry("Lx<;",hm)); }*/ }