]> source.dussan.org Git - aspectj.git/commitdiff
invokedynamic tidyup - handle calling getClassname on it invokedynamic
authorAndy Clement <aclement@vmware.com>
Mon, 19 Mar 2012 20:42:20 +0000 (13:42 -0700)
committerAndy Clement <aclement@vmware.com>
Mon, 19 Mar 2012 20:42:20 +0000 (13:42 -0700)
bcel-builder/src/org/aspectj/apache/bcel/generic/InvokeDynamic.java
lib/bcel/bcel-src.zip
lib/bcel/bcel-verifier-src.zip
lib/bcel/bcel-verifier.jar
lib/bcel/bcel.jar
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java

index 951f9b1b36742e436e3dbb03b89e12d2ed3102a2..b3c7ba85ace2010571837a87d8b8e49a16620032 100644 (file)
@@ -58,11 +58,9 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 
 import org.aspectj.apache.bcel.Constants;
-import org.aspectj.apache.bcel.classfile.ConstantCP;
 import org.aspectj.apache.bcel.classfile.ConstantInvokeDynamic;
 import org.aspectj.apache.bcel.classfile.ConstantNameAndType;
 import org.aspectj.apache.bcel.classfile.ConstantPool;
-import org.aspectj.apache.bcel.classfile.ConstantUtf8;
 
 /**
  * INVOKEDYNAMIC
@@ -125,7 +123,7 @@ public final class InvokeDynamic extends InvokeInstruction {
        }
        
        public String getClassName(ConstantPool cp) {
-               throw new IllegalStateException("nyi");
+               throw new IllegalStateException("there is no classname for invokedynamic");
        }
 
 }
index b512f9051de9b555b4ff91ca44ba018df769c40e..9150034a6787e2cf053222830f4e23ebe4d1cbed 100644 (file)
Binary files a/lib/bcel/bcel-src.zip and b/lib/bcel/bcel-src.zip differ
index c764a9a28df2435595580fd55f199defb568c38a..ba3f777d146700088fbbcae24ea857870d1479a9 100644 (file)
Binary files a/lib/bcel/bcel-verifier-src.zip and b/lib/bcel/bcel-verifier-src.zip differ
index fed7db520a560bcdff3fc88cb1a527492a9bfd76..a86266c05ed58bb99e498d92795910c2cc88c7ba 100644 (file)
Binary files a/lib/bcel/bcel-verifier.jar and b/lib/bcel/bcel-verifier.jar differ
index c439c077679dffb2d42c2f5f0f393be8791466e7..3a1fb89e505cfe2142e8896786ea8e3617913bff 100644 (file)
Binary files a/lib/bcel/bcel.jar and b/lib/bcel/bcel.jar differ
index fa3ff3379166e113828897ecfd482d4d74d82a9b..8874dcd0358ee4912c612157fd6a187ae7edf41a 100644 (file)
@@ -486,12 +486,9 @@ public class AjcMemberMaker {
         * This field goes on top-most implementers of the interface the field is declared onto
         */
        public static ResolvedMember interFieldInterfaceField(ResolvedMember field, UnresolvedType onClass, UnresolvedType aspectType) {
-//             return new ResolvedMemberImpl(Member.FIELD, onClass, makePublicNonFinal(field.getModifiers()), field.getReturnType(),
-//                             NameMangler.interFieldInterfaceField(aspectType, field.getDeclaringType(), field.getName()), UnresolvedType.NONE,
-//                             UnresolvedType.NONE);
-
-               // TODO what about non public fields, can you have those?
-               return interFieldClassField(field,aspectType,true);
+               return new ResolvedMemberImpl(Member.FIELD, onClass, makePublicNonFinal(field.getModifiers()), field.getReturnType(),
+                               NameMangler.interFieldInterfaceField(aspectType, field.getDeclaringType(), field.getName()), UnresolvedType.NONE,
+                               UnresolvedType.NONE);
        }
 
        /**
index 0bba33032c6bc22c76273e6d378a666ff686acad..7b904778f1f891b857c8e03e70a8142cb18d714b 100644 (file)
@@ -674,8 +674,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                        return false;
                }
 
-               if (m1.getKind() == Member.FIELD && m1.getDeclaringType().equals(m2.getDeclaringType())) {
-                       return true ;
+               if (m1.getKind() == Member.FIELD) {
+                       return m1.getDeclaringType().equals(m2.getDeclaringType());
                } else if (m1.getKind() == Member.POINTCUT) {
                        return true;
                }
@@ -1735,13 +1735,12 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                        }
                }
 
-               boolean needsAdding = true;
-               boolean needsToBeAddedEarlier = false;
                // now compare to existingMungers
                for (Iterator<ConcreteTypeMunger> i = interTypeMungers.iterator(); i.hasNext();) {
                        ConcreteTypeMunger existingMunger = i.next();
                        if (conflictingSignature(existingMunger.getSignature(), munger.getSignature())) {
-                               // System.err.println("match " + munger + " with " + existingMunger);
+                               // System.err.println("match " + munger + " with " +
+                               // existingMunger);
                                if (isVisible(munger.getSignature().getModifiers(), munger.getAspectType(), existingMunger.getAspectType())) {
                                        // System.err.println("    is visible");
                                        int c = compareMemberPrecedence(sig, existingMunger.getSignature());
@@ -1752,22 +1751,11 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                                        if (c < 0) {
                                                // the existing munger dominates the new munger
                                                checkLegalOverride(munger.getSignature(), existingMunger.getSignature(), 0x11, null);
-                                               needsAdding = false;
-//                                             return;
-                                               if (munger.getSignature().getKind()==Member.FIELD && 
-                                                               munger.getSignature().getDeclaringType().resolve(world).isInterface()) {
-                                                       needsAdding=true;
-                                               }
-                                               break;
+                                               return;
                                        } else if (c > 0) {
                                                // the new munger dominates the existing one
                                                checkLegalOverride(existingMunger.getSignature(), munger.getSignature(), 0x11, null);
-                                               if (munger.getSignature().getKind()==Member.FIELD && 
-                                                               munger.getSignature().getDeclaringType().resolve(world).isInterface()) {
-                                                       needsToBeAddedEarlier = true;
-                                               } else {
-                                                       i.remove();
-                                               }
+                                               i.remove();
                                                break;
                                        } else {
                                                interTypeConflictError(munger, existingMunger);
@@ -1781,13 +1769,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                // we are adding the parameterized form of the ITD to the list of
                // mungers. Within it, the munger knows the original declared
                // signature for the ITD so it can be retrieved.
-               if (needsAdding) {
-                       if (!needsToBeAddedEarlier) {
-                               interTypeMungers.add(munger);                           
-                       } else {
-                               interTypeMungers.add(0,munger);
-                       }
-               }
+               interTypeMungers.add(munger);
        }
 
        /**
index ebdf20c3e8c773ffefa25d99f70d48bd9a320aac..77a50869cd485a6d2969ba28d0004815ae37a115 100644 (file)
@@ -25,7 +25,7 @@ import org.aspectj.weaver.UnresolvedType;
  */ 
 public class Ajc170Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
-
+/*
        public void testPublicITDFs_pr73507_1() {
                runTest("public ITDfs - 1");
        }
@@ -41,6 +41,7 @@ public class Ajc170Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
        public void testPublicITDFs_pr73507_4() {
                runTest("public ITDfs - 4");
        }
+*/
 
        public void testBCExceptionAnnoDecp_371998() {
                runTest("BCException anno decp");
index 59fb837c01a0e2a17dab1dffc9c20303b04995e7..fbeb09e977b83246ec33d201eacdafdd7756737b 100644 (file)
@@ -2769,7 +2769,9 @@ class BcelClassWeaver implements IClassWeaver {
                                        // AspectJ-1.{0,1}
                                }
                        } else {
-                               matchInvokeInstruction(mg, ih, ii, enclosingShadow, shadowAccumulator);
+                               if (ii.getOpcode()!=Constants.INVOKEDYNAMIC) {
+                                       matchInvokeInstruction(mg, ih, ii, enclosingShadow, shadowAccumulator);
+                               }
                        }
                } else if (world.isJoinpointArrayConstructionEnabled() && i.isArrayCreationInstruction()) {
                        if (canMatch(Shadow.ConstructorCall)) {
index 4211475f4ac40f092e1d02503dab7b64284ec9dc..fcf61a085e7ddb5e3ff18242c7b39bb088d6a304 100644 (file)
@@ -24,7 +24,6 @@ import java.util.Set;
 
 import org.aspectj.apache.bcel.Constants;
 import org.aspectj.apache.bcel.classfile.ConstantPool;
-import org.aspectj.apache.bcel.classfile.Field;
 import org.aspectj.apache.bcel.classfile.Signature;
 import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
 import org.aspectj.apache.bcel.generic.FieldGen;
@@ -1881,8 +1880,6 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
                                LazyMethodGen mg1 = makeMethodGen(gen, AjcMemberMaker.interFieldInterfaceSetter(field, onType, aspectType));
                                gen.addMethodGen(mg1);
                        } else {
-                               if (gen.fieldExists(field.getName())) return false;
-                               
                                weaver.addInitializer(this);
                                ResolvedMember newField = AjcMemberMaker.interFieldClassField(field, aspectType,
                                                munger.version == NewFieldTypeMunger.VersionTwo);
@@ -1912,33 +1909,29 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
                        }
                        return true;
                } else if (onInterface && gen.getType().isTopmostImplementor(onType)) {
-                       // we know that we can't be static since we don't allow statics on interfaces
+                       // wew know that we can't be static since we don't allow statics on
+                       // interfaces
                        if (Modifier.isStatic(field.getModifiers())) {
                                throw new RuntimeException("unimplemented");
                        }
-                       
-                       
+                       weaver.addInitializer(this);
+                       // System.err.println("impl body on " + gen.getType() + " for " +
+                       // munger);
+
                        Type fieldType = BcelWorld.makeBcelType(field.getType());
-                       String fieldname = field.getName();
-                       if (!gen.fieldExists(fieldname)) {
-                               weaver.addInitializer(this);
-                               // System.err.println("impl body on " + gen.getType() + " for " +
-                               // munger);
-       
-       
-                               FieldGen fg = makeFieldGen(gen, AjcMemberMaker.interFieldInterfaceField(field, onType, aspectType));
-       
-                               if (annotationsOnRealMember != null) {
-                                       for (int i = 0; i < annotationsOnRealMember.length; i++) {
-                                               AnnotationAJ annotationX = annotationsOnRealMember[i];
-                                               AnnotationGen a = ((BcelAnnotation) annotationX).getBcelAnnotation();
-                                               AnnotationGen ag = new AnnotationGen(a, weaver.getLazyClassGen().getConstantPool(), true);
-                                               fg.addAnnotation(ag);
-                                       }
+
+                       FieldGen fg = makeFieldGen(gen, AjcMemberMaker.interFieldInterfaceField(field, onType, aspectType));
+
+                       if (annotationsOnRealMember != null) {
+                               for (int i = 0; i < annotationsOnRealMember.length; i++) {
+                                       AnnotationAJ annotationX = annotationsOnRealMember[i];
+                                       AnnotationGen a = ((BcelAnnotation) annotationX).getBcelAnnotation();
+                                       AnnotationGen ag = new AnnotationGen(a, weaver.getLazyClassGen().getConstantPool(), true);
+                                       fg.addAnnotation(ag);
                                }
-                               fieldname = fg.getName();
-                               gen.addField(fg, getSourceLocation());
                        }
+
+                       gen.addField(fg, getSourceLocation());
                        // this uses a shadow munger to add init method to constructors
                        // weaver.getShadowMungers().add(makeInitCallShadowMunger(initMethod)
                        // );
@@ -1948,10 +1941,10 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
                        InstructionList il = new InstructionList();
                        InstructionFactory fact = gen.getFactory();
                        if (Modifier.isStatic(field.getModifiers())) {
-                               il.append(fact.createFieldAccess(gen.getClassName(), fieldname, fieldType, Constants.GETSTATIC));
+                               il.append(fact.createFieldAccess(gen.getClassName(), fg.getName(), fieldType, Constants.GETSTATIC));
                        } else {
                                il.append(InstructionConstants.ALOAD_0);
-                               il.append(fact.createFieldAccess(gen.getClassName(), fieldname, fieldType, Constants.GETFIELD));
+                               il.append(fact.createFieldAccess(gen.getClassName(), fg.getName(), fieldType, Constants.GETFIELD));
                        }
                        il.append(InstructionFactory.createReturn(fieldType));
                        mg.getBody().insert(il);
@@ -1981,11 +1974,11 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
                        InstructionList il1 = new InstructionList();
                        if (Modifier.isStatic(field.getModifiers())) {
                                il1.append(InstructionFactory.createLoad(fieldType, 0));
-                               il1.append(fact.createFieldAccess(gen.getClassName(), fieldname, fieldType, Constants.PUTSTATIC));
+                               il1.append(fact.createFieldAccess(gen.getClassName(), fg.getName(), fieldType, Constants.PUTSTATIC));
                        } else {
                                il1.append(InstructionConstants.ALOAD_0);
                                il1.append(InstructionFactory.createLoad(fieldType, 1));
-                               il1.append(fact.createFieldAccess(gen.getClassName(), fieldname, fieldType, Constants.PUTFIELD));
+                               il1.append(fact.createFieldAccess(gen.getClassName(), fg.getName(), fieldType, Constants.PUTFIELD));
                        }
                        il1.append(InstructionFactory.createReturn(Type.VOID));
                        mg1.getBody().insert(il1);