]> source.dussan.org Git - javassist.git/commitdiff
made the java.util.proxy package support stack map tables.
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Sun, 3 Jun 2007 02:33:47 +0000 (02:33 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Sun, 3 Jun 2007 02:33:47 +0000 (02:33 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@380 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/util/proxy/ProxyFactory.java

index a34f9a4d8ed1b6d025e2af3a224553a8af49602b..be9eb25d57df8c742d832588f2fa3a9fc61fa125 100644 (file)
@@ -764,19 +764,26 @@ public class ProxyFactory {
 
         code.addAload(0);
         code.addGetstatic(thisClassName, DEFAULT_INTERCEPTOR, HANDLER_TYPE);
-        code.addOpcode(Opcode.DUP);
+        code.addPutfield(thisClassName, HANDLER, HANDLER_TYPE);
+        code.addGetstatic(thisClassName, DEFAULT_INTERCEPTOR, HANDLER_TYPE);
         code.addOpcode(Opcode.IFNONNULL);
-        code.addIndex(7);
-        code.addOpcode(Opcode.POP);
+        code.addIndex(10);
+        code.addAload(0);
         code.addGetstatic(NULL_INTERCEPTOR_HOLDER, DEFAULT_INTERCEPTOR, HANDLER_TYPE);
         code.addPutfield(thisClassName, HANDLER, HANDLER_TYPE);
+        int pc = code.currentPc();
 
         code.addAload(0);
         int s = addLoadParameters(code, cons.getParameterTypes(), 1);
         code.addInvokespecial(superClass.getName(), "<init>", desc);
         code.addOpcode(Opcode.RETURN);
         code.setMaxLocals(s + 1);
-        minfo.setCodeAttribute(code.toCodeAttribute());
+        CodeAttribute ca = code.toCodeAttribute();
+        minfo.setCodeAttribute(ca);
+
+        StackMapTable.Writer writer = new StackMapTable.Writer(32);
+        writer.sameFrame(pc);
+        ca.setAttribute(writer.toStackMapTable(cp));
         return minfo;
     }
 
@@ -840,7 +847,8 @@ public class ProxyFactory {
         callFindMethod(code, "findSuperMethod", arrayVar, origIndex, meth.getName(), desc);
         callFindMethod(code, "findMethod", arrayVar, delIndex, delegatorName, desc);
 
-        code.write16bit(pc, code.currentPc() - pc + 1);
+        int pc2 = code.currentPc();
+        code.write16bit(pc, pc2 - pc + 1);
         code.addAload(0);
         code.addGetfield(thisClassName, HANDLER, HANDLER_TYPE);
         code.addAload(0);
@@ -861,7 +869,12 @@ public class ProxyFactory {
         addUnwrapper(code, retType);
         addReturn(code, retType);
 
-        forwarder.setCodeAttribute(code.toCodeAttribute());
+        CodeAttribute ca = code.toCodeAttribute();
+        forwarder.setCodeAttribute(ca);
+        StackMapTable.Writer writer = new StackMapTable.Writer(32);
+        writer.appendFrame(pc2, new int[] { StackMapTable.OBJECT },
+                           new int[] { cp.addClassInfo(HOLDER_TYPE) });
+        ca.setAttribute(writer.toStackMapTable(cp));
         return forwarder;
     }