diff options
7 files changed, 79 insertions, 32 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java index 3f2aab4e9..18380cbe6 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java @@ -226,11 +226,21 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate { return resolvedPointcutDeclaration; } + /** + * This method may not return all fields, for example it may + * not include the ajc$initFailureCause or ajc$perSingletonInstance + * fields - see bug 129613 + */ public ResolvedMember[] getDeclaredFields() { if (declaredFields == null) fillDeclaredMembers(); return declaredFields; } + /** + * This method may not return all methods, for example it may + * not include clinit, aspectOf, hasAspect or ajc$postClinit + * methods - see bug 129613 + */ public ResolvedMember[] getDeclaredMethods() { if (declaredMethods == null) fillDeclaredMembers(); return declaredMethods; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java index 799130ba2..679d0c6bf 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -34,6 +34,7 @@ import org.aspectj.asm.IRelationshipMap; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.Message; import org.aspectj.bridge.SourceLocation; +import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException; @@ -44,6 +45,7 @@ import org.aspectj.org.eclipse.jdt.internal.core.builder.ReferenceCollection; import org.aspectj.org.eclipse.jdt.internal.core.builder.StringSet; import org.aspectj.util.FileUtil; import org.aspectj.weaver.IWeaver; +import org.aspectj.weaver.NameMangler; import org.aspectj.weaver.ReferenceType; import org.aspectj.weaver.ResolvedMember; import org.aspectj.weaver.ResolvedType; @@ -816,12 +818,12 @@ public class AjState { } // generic signature - if (!equal(reader.getGenericSignature(),existingType.genericSignature)) { + if (!CharOperation.equals(reader.getGenericSignature(),existingType.genericSignature)) { return true; } // superclass name - if (!equal(reader.getSuperclassName(),existingType.superclassName)) { + if (!CharOperation.equals(reader.getSuperclassName(),existingType.superclassName)) { return true; } @@ -835,7 +837,7 @@ public class AjState { } new_interface_loop: for (int i = 0; i < newIfs.length; i++) { for (int j = 0; j < existingIfs.length; j++) { - if (equal(existingIfs[j],newIfs[i])) { + if (CharOperation.equals(existingIfs[j],newIfs[i])) { continue new_interface_loop; } } @@ -846,17 +848,27 @@ public class AjState { MemberStructure[] existingFields = existingType.fields; IBinaryField[] newFields = reader.getFields(); if (newFields == null) { newFields = new IBinaryField[0]; } - if (newFields.length != existingFields.length) { + // remove any ajc$XXX fields from those we compare with + // the existing fields - bug 129163 + List nonGenFields = new ArrayList(); + for (int i = 0; i < newFields.length; i++) { + IBinaryField field = newFields[i]; + if (!CharOperation.prefixEquals(NameMangler.AJC_DOLLAR_PREFIX,field.getName())) { + nonGenFields.add(field); + } + } + if (nonGenFields.size() != existingFields.length) { return true; } - new_field_loop: for (int i = 0; i < newFields.length; i++) { - char[] fieldName = newFields[i].getName(); + new_field_loop: for (Iterator iter = nonGenFields.iterator(); iter.hasNext();) { + IBinaryField field = (IBinaryField) iter.next(); + char[] fieldName = field.getName(); for (int j = 0; j < existingFields.length; j++) { - if (equal(existingFields[j].name,fieldName)) { - if (!modifiersEqual(newFields[i].getModifiers(),existingFields[j].modifiers)) { + if (CharOperation.equals(existingFields[j].name,fieldName)) { + if (!modifiersEqual(field.getModifiers(),existingFields[j].modifiers)) { return true; } - if (!equal(existingFields[j].signature,newFields[i].getTypeName())) { + if (!CharOperation.equals(existingFields[j].signature,field.getTypeName())) { return true; } continue new_field_loop; @@ -869,20 +881,34 @@ public class AjState { MemberStructure[] existingMethods = existingType.methods; IBinaryMethod[] newMethods = reader.getMethods(); if (newMethods == null) { newMethods = new IBinaryMethod[0]; } - if (newMethods.length != existingMethods.length) { + // remove the aspectOf, hasAspect, clinit and ajc$XXX methods + // from those we compare with the existing methods - bug 129163 + List nonGenMethods = new ArrayList(); + for (int i = 0; i < newMethods.length; i++) { + IBinaryMethod method = newMethods[i]; + char[] methodName = method.getSelector(); + if (!CharOperation.equals(methodName,NameMangler.METHOD_ASPECTOF) && + !CharOperation.equals(methodName,NameMangler.METHOD_HASASPECT) && + !CharOperation.equals(methodName,NameMangler.STATIC_INITIALIZER) && + !CharOperation.prefixEquals(NameMangler.AJC_DOLLAR_PREFIX,methodName)) { + nonGenMethods.add(method); + } + } + if (nonGenMethods.size() != existingMethods.length) { return true; } - new_method_loop: for (int i = 0; i < newMethods.length; i++) { - char[] methodName = newMethods[i].getSelector(); + new_method_loop: for (Iterator iter = nonGenMethods.iterator(); iter.hasNext();) { + IBinaryMethod method = (IBinaryMethod) iter.next(); + char[] methodName = method.getSelector(); for (int j = 0; j < existingMethods.length; j++) { - if (equal(existingMethods[j].name,methodName)) { + if (CharOperation.equals(existingMethods[j].name,methodName)) { // candidate match - if (!equal(newMethods[i].getMethodDescriptor(),existingMethods[j].signature)) { + if (!CharOperation.equals(method.getMethodDescriptor(),existingMethods[j].signature)) { continue; // might be overloading } else { // matching sigs - if (!modifiersEqual(newMethods[i].getModifiers(),existingMethods[j].modifiers)) { + if (!modifiersEqual(method.getModifiers(),existingMethods[j].modifiers)) { return true; } continue new_method_loop; @@ -904,22 +930,6 @@ public class AjState { return (eclipseModifiers == resolvedTypeModifiers); } - private boolean equal(char[] c1, char[] c2) { - if (c1 == null && c2 == null) { - return true; - } - if (c1 == null || c2 == null) { - return false; - } - if (c1.length != c2.length) { - return false; - } - for (int i = 0; i < c1.length; i++) { - if (c1[i] != c2[i]) return false; - } - return true; - } - private static StringSet makeStringSet(List strings) { StringSet ret = new StringSet(strings.size()); for (Iterator iter = strings.iterator(); iter.hasNext();) { diff --git a/weaver/src/org/aspectj/weaver/NameMangler.java b/weaver/src/org/aspectj/weaver/NameMangler.java index 4dfd751b9..7337305bc 100644 --- a/weaver/src/org/aspectj/weaver/NameMangler.java +++ b/weaver/src/org/aspectj/weaver/NameMangler.java @@ -20,9 +20,12 @@ public class NameMangler { private NameMangler() { throw new RuntimeException("static"); } - + public static final char[] AJC_DOLLAR_PREFIX = {'a', 'j', 'c','$'}; public static final String PREFIX = "ajc$"; public static final String ITD_PREFIX = PREFIX + "interType$"; + public static final char[] METHOD_ASPECTOF = {'a', 's', 'p','e','c','t','O','f'}; + public static final char[] METHOD_HASASPECT = {'h', 'a', 's','A','s','p','e','c','t'}; + public static final char[] STATIC_INITIALIZER = {'<', 'c', 'l','i','n','i','t','>'}; public static final String CFLOW_STACK_TYPE = "org.aspectj.runtime.internal.CFlowStack"; public static final String CFLOW_COUNTER_TYPE="org.aspectj.runtime.internal.CFlowCounter"; diff --git a/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java b/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java index 5891b9bc8..927b174be 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java @@ -406,4 +406,6 @@ public abstract class ResolvedTypeMunger { public boolean isLateMunger() { return false; } + + } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelCflowCounterFieldAdder.java b/weaver/src/org/aspectj/weaver/bcel/BcelCflowCounterFieldAdder.java index 08bb03e87..671e10faa 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelCflowCounterFieldAdder.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelCflowCounterFieldAdder.java @@ -85,5 +85,8 @@ public class BcelCflowCounterFieldAdder extends BcelTypeMunger { public boolean matches(ResolvedType onType) { return onType.equals(cflowCounterField.getDeclaringType()); } + public boolean existsToSupportShadowMunging() { + return true; + } } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelCflowStackFieldAdder.java b/weaver/src/org/aspectj/weaver/bcel/BcelCflowStackFieldAdder.java index 2ed447ac4..df9725ac2 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelCflowStackFieldAdder.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelCflowStackFieldAdder.java @@ -74,5 +74,8 @@ public class BcelCflowStackFieldAdder extends BcelTypeMunger { public boolean matches(ResolvedType onType) { return onType.equals(cflowStackField.getDeclaringType()); } + public boolean existsToSupportShadowMunging() { + return true; + } } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index e291cc3e3..156525993 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -1644,5 +1644,21 @@ public class BcelTypeMunger extends ConcreteTypeMunger { public List /*String*/ getTypeVariableAliases() { return munger.getTypeVariableAliases(); } + + /** + * Some type mungers are created purely to help with the implementation of shadow mungers. + * For example to support the cflow() pointcut we create a new cflow field in the aspect, and + * that is added via a BcelCflowCounterFieldAdder. + * + * During compilation we need to compare sets of type mungers, and if some only come into + * existence after the 'shadowy' type things have been processed, we need to ignore + * them during the comparison. + * + * Returning true from this method indicates the type munger exists to support 'shadowy' stuff - + * and so can be ignored in some comparison. + */ + public boolean existsToSupportShadowMunging() { + return false; // Does this need to delegate to the ResolvedTypeMunger field held in the BcelTypeMunger? + } }
\ No newline at end of file |