diff options
author | Andy Clement <aclement@vmware.com> | 2012-03-19 13:42:20 -0700 |
---|---|---|
committer | Andy Clement <aclement@vmware.com> | 2012-03-19 13:42:20 -0700 |
commit | afae1fc59a4d857b1e19f282b7a38fe061afe738 (patch) | |
tree | 8708048b4d94d484fe07f7c7677eb372ffdcbaf4 /weaver | |
parent | 1c0f36ea2026aff22afd9c9d22782db8233c8b95 (diff) | |
download | aspectj-afae1fc59a4d857b1e19f282b7a38fe061afe738.tar.gz aspectj-afae1fc59a4d857b1e19f282b7a38fe061afe738.zip |
invokedynamic tidyup - handle calling getClassname on itinvokedynamic
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java | 4 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java | 49 |
2 files changed, 24 insertions, 29 deletions
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); |