@@ -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"); | |||
} | |||
} |
@@ -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); | |||
} | |||
/** |
@@ -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); | |||
} | |||
/** |
@@ -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"); |
@@ -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)) { |
@@ -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); |