]> source.dussan.org Git - aspectj.git/commitdiff
445395: more support for invokedynamic
authorAndy Clement <aclement@gopivotal.com>
Tue, 30 Sep 2014 17:50:54 +0000 (10:50 -0700)
committerAndy Clement <aclement@gopivotal.com>
Tue, 30 Sep 2014 17:50:54 +0000 (10:50 -0700)
bcel-builder/src/org/aspectj/apache/bcel/ConstantsInitializer.java
bcel-builder/src/org/aspectj/apache/bcel/ExceptionConstants.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/BootstrapMethods.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantInvokeDynamic.java
bcel-builder/src/org/aspectj/apache/bcel/classfile/ConstantPool.java
bcel-builder/src/org/aspectj/apache/bcel/generic/InstructionList.java
lib/bcel/bcel-src.zip
lib/bcel/bcel-verifier.jar
lib/bcel/bcel.jar

index 9e19c417dec7d61566b36bfb863a28dff2af7f21..b9bc0d49fc19168bd8ae678cc0d6cfed56008e2e 100644 (file)
@@ -337,6 +337,11 @@ public class ConstantsInitializer {
                                | Constants.INDEXED;
                Constants.instExcs[Constants.INVOKEVIRTUAL] = ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION_INVOKESPECIAL_INVOKEVIRTUAL;
 
+               Constants.instFlags[Constants.INVOKEDYNAMIC] = Constants.EXCEPTION_THROWER | Constants.CP_INST | Constants.LOADCLASS_INST
+                               | Constants.INDEXED;
+               // TBD
+               // Constants.instExcs[Constants.INVOKEDYNAMIC] = ExceptionConstants.EXCS_INTERFACE_METHOD_RESOLUTION_INVOKESPECIAL_INVOKEVIRTUAL;
+
                //@formatter:off
                char[] lengths = // . = varies in length, / = undefined
                ("1111111111111111" + // nop > dconst_1
index 34455be3596ee1a934586b43b1a2098d76e6336c..0c918c8ea155dc54714cbc84cc30d3fe07102a7f 100644 (file)
@@ -135,6 +135,7 @@ public interface ExceptionConstants {
                        ILLEGAL_ACCESS_ERROR, ABSTRACT_METHOD_ERROR, UNSATISFIED_LINK_ERROR };
        public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION_INVOKESPECIAL_INVOKEVIRTUAL = { INCOMPATIBLE_CLASS_CHANGE_ERROR,
                        NULL_POINTER_EXCEPTION, ABSTRACT_METHOD_ERROR, UNSATISFIED_LINK_ERROR };
+//     public static final Class[] EXCS_INVOKEDYNAMIC = { BOOTSTRAP_METHOD_ERROR};
 
        public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION_INVOKESTATIC = { INCOMPATIBLE_CLASS_CHANGE_ERROR,
                        UNSATISFIED_LINK_ERROR };
index b4638bc293f4226a92a8948a5240dfd43f8efd5b..a5216f2ef2e411c746a3bea2cad56668c0f86f27 100644 (file)
@@ -99,7 +99,7 @@ public final class BootstrapMethods extends Attribute {
                isInPackedState = true;
        }
        
-       static class BootstrapMethod {
+       public static class BootstrapMethod {
                private int bootstrapMethodRef;
                private int[] bootstrapArguments;
 
@@ -116,7 +116,7 @@ public final class BootstrapMethods extends Attribute {
                        return bootstrapArguments;
                }
                
-               BootstrapMethod(int bootstrapMethodRef, int[] bootstrapArguments) {
+               public BootstrapMethod(int bootstrapMethodRef, int[] bootstrapArguments) {
                        this.bootstrapMethodRef = bootstrapMethodRef;
                        this.bootstrapArguments = bootstrapArguments;
                }
@@ -138,6 +138,12 @@ public final class BootstrapMethods extends Attribute {
                        }
                }
                
+               public final int getLength() {
+                       return 2 /*bootstrapMethodRef*/+
+                                       2 /*number of arguments*/+
+                                       2 * bootstrapArguments.length;
+               }
+               
        }
        
        // Unpacks the byte array into the table
index be71b4e8efef454dcdaf5ca36b1fbcaa95b08bb9..0d263aa6524a4bf024b0605a6a5081f0704d763f 100644 (file)
@@ -109,6 +109,10 @@ public final class ConstantInvokeDynamic extends Constant {
        public final int getNameAndTypeIndex() {
                return nameAndTypeIndex;
        }
+       
+       public final int getBootstrapMethodAttrIndex() {
+               return bootstrapMethodAttrIndex;
+       }
 
        @Override
        public final String toString() {
index fe27b5fe5d7dcef84ca0856a731b840aba3e5b58..4e160ba3d648992573224c88fd4a8b5503326f94 100644 (file)
@@ -586,6 +586,20 @@ public class ConstantPool implements Node {
 
                        return addNameAndType(u8.getValue(), u8_2.getValue());
                }
+               
+               case Constants.CONSTANT_InvokeDynamic: {
+                       ConstantInvokeDynamic cid = (ConstantInvokeDynamic)c;
+                       int index1 = cid.getBootstrapMethodAttrIndex();
+                       ConstantNameAndType cnat = (ConstantNameAndType)constants[cid.getNameAndTypeIndex()];
+                       ConstantUtf8 name = (ConstantUtf8) constants[cnat.getNameIndex()];
+                       ConstantUtf8 signature = (ConstantUtf8) constants[cnat.getSignatureIndex()];
+                       int index2 = addNameAndType(name.getValue(), signature.getValue());
+                       return addInvokeDynamic(index1,index2);
+               }
+               
+               case Constants.CONSTANT_MethodHandle:
+                       ConstantMethodHandle cmh = (ConstantMethodHandle)c;
+                       return addMethodHandle(cmh.getReferenceKind(),addConstant(constants[cmh.getReferenceIndex()],cp));
 
                case Constants.CONSTANT_Utf8:
                        return addUtf8(((ConstantUtf8) c).getValue());
@@ -601,6 +615,10 @@ public class ConstantPool implements Node {
 
                case Constants.CONSTANT_Integer:
                        return addInteger(((ConstantInteger) c).getValue());
+                       
+               case Constants.CONSTANT_MethodType:
+                       ConstantMethodType cmt = (ConstantMethodType)c;
+                       return addMethodType(addConstant(constants[cmt.getDescriptorIndex()],cp));
 
                case Constants.CONSTANT_InterfaceMethodref:
                case Constants.CONSTANT_Methodref:
@@ -636,6 +654,20 @@ public class ConstantPool implements Node {
                        throw new RuntimeException("Unknown constant type " + c);
                }
        }
+       
+       public int addMethodHandle(byte referenceKind, int referenceIndex) {
+               adjustSize();
+               int ret = poolSize;
+               pool[poolSize++] = new ConstantMethodHandle(referenceKind, referenceIndex);
+               return ret;
+       }
+       
+       public int addMethodType(int descriptorIndex) {
+               adjustSize();
+               int ret = poolSize;
+               pool[poolSize++] = new ConstantMethodType(descriptorIndex);
+               return ret;
+       }
 
        // OPTIMIZE should put it in the cache now
        public int addMethodref(String class_name, String method_name, String signature) {
@@ -651,6 +683,13 @@ public class ConstantPool implements Node {
                pool[poolSize++] = new ConstantMethodref(class_index, name_and_type_index);
                return ret;
        }
+       
+       public int addInvokeDynamic(int bootstrapMethodIndex, int constantNameAndTypeIndex) {
+               adjustSize();
+               int ret = poolSize;
+               pool[poolSize++] = new ConstantInvokeDynamic(bootstrapMethodIndex, constantNameAndTypeIndex);
+               return ret;
+       }
 
        public int addInterfaceMethodref(String class_name, String method_name, String signature) {
                int ret = lookupInterfaceMethodref(class_name, method_name, signature);
index 25f97836fcc90f25164c554af9777fe00bdc20f0..b08a2b77cdd3b2445e4f979d3ec2febc88379bac 100644 (file)
@@ -1150,7 +1150,6 @@ public class InstructionList implements Serializable {
        public void replaceConstantPool(ConstantPool old_cp, ConstantPool new_cp) {
                for (InstructionHandle ih = start; ih != null; ih = ih.next) {
                        Instruction i = ih.instruction;
-
                        if (i.isConstantPoolInstruction()) {
                                InstructionCP ci = (InstructionCP) i;
                                Constant c = old_cp.getConstant(ci.getIndex());
@@ -1165,7 +1164,7 @@ public class InstructionList implements Serializable {
        }
 
        /**
-        * Delete contents of list. Provides besser memory utilization, because the system then may reuse the instruction handles. This
+        * Delete contents of list. Provides better memory utilization, because the system then may reuse the instruction handles. This
         * method is typically called right after <href="MethodGen.html#getMethod()">MethodGen.getMethod()</a>.
         */
        public void dispose() {
index 5996c3ced1ef8bcc213b2f6953d57caa48174e60..2d0a3b5f3e75d624073f36a670421789e8edff27 100644 (file)
Binary files a/lib/bcel/bcel-src.zip and b/lib/bcel/bcel-src.zip differ
index 2465224399ae156a7fdb4e8d81f9e4a771841b6a..46a5a0c442dc89983ad90a614b5e6438e8c95d5c 100644 (file)
Binary files a/lib/bcel/bcel-verifier.jar and b/lib/bcel/bcel-verifier.jar differ
index 5da7b48426992124ad2567a55c8d98803f35120a..097532e75ca362ad3953ef6416d14889dfaf6238 100644 (file)
Binary files a/lib/bcel/bcel.jar and b/lib/bcel/bcel.jar differ