From: Andy Clement Date: Mon, 19 Mar 2012 20:42:20 +0000 (-0700) Subject: invokedynamic tidyup - handle calling getClassname on it X-Git-Tag: V1_7_0RC1~22 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=afae1fc59a4d857b1e19f282b7a38fe061afe738;p=aspectj.git invokedynamic tidyup - handle calling getClassname on it --- diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/InvokeDynamic.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/InvokeDynamic.java index 951f9b1b3..b3c7ba85a 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/InvokeDynamic.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/InvokeDynamic.java @@ -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"); } } diff --git a/lib/bcel/bcel-src.zip b/lib/bcel/bcel-src.zip index b512f9051..9150034a6 100644 Binary files a/lib/bcel/bcel-src.zip and b/lib/bcel/bcel-src.zip differ diff --git a/lib/bcel/bcel-verifier-src.zip b/lib/bcel/bcel-verifier-src.zip index c764a9a28..ba3f777d1 100644 Binary files a/lib/bcel/bcel-verifier-src.zip and b/lib/bcel/bcel-verifier-src.zip differ diff --git a/lib/bcel/bcel-verifier.jar b/lib/bcel/bcel-verifier.jar index fed7db520..a86266c05 100644 Binary files a/lib/bcel/bcel-verifier.jar and b/lib/bcel/bcel-verifier.jar differ diff --git a/lib/bcel/bcel.jar b/lib/bcel/bcel.jar index c439c0776..3a1fb89e5 100644 Binary files a/lib/bcel/bcel.jar and b/lib/bcel/bcel.jar differ diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java b/org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java index fa3ff3379..8874dcd03 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java @@ -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); } /** diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java index 0bba33032..7b904778f 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java @@ -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 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); } /** diff --git a/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java b/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java index ebdf20c3e..77a50869c 100644 --- a/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java @@ -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"); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index 59fb837c0..fbeb09e97 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -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)) { diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index 4211475f4..fcf61a085 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -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);