summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2010-06-11 22:58:10 +0000
committeraclement <aclement>2010-06-11 22:58:10 +0000
commit9a73bdb1c732b129cb05ce06e61f6505f6e078ab (patch)
tree2d3d8c2736f8a5e5d374b1b39fd45de03beebc3e
parent3dc83d6cc87aa78071d95568a596a1eebd48e88a (diff)
downloadaspectj-9a73bdb1c732b129cb05ce06e61f6505f6e078ab.tar.gz
aspectj-9a73bdb1c732b129cb05ce06e61f6505f6e078ab.zip
itd inners:
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java132
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java125
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java1
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberClassBinding.java70
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/IntertypeMemberTypeFinder.java6
5 files changed, 201 insertions, 133 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
index e9356a783..cd8c0175d 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
@@ -1,5 +1,5 @@
/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
+ * Copyright (c) 2002-2010 Contributors
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
@@ -7,9 +7,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * PARC initial implementation
+ * PARC, Andy Clement (SpringSource)
* ******************************************************************/
-
package org.aspectj.ajdt.internal.compiler.ast;
import java.lang.reflect.Modifier;
@@ -19,12 +18,14 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.aspectj.ajdt.internal.compiler.ast.AccessForInlineVisitor.SuperAccessMethodPair;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseScope;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseSourceType;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseTypeMunger;
import org.aspectj.ajdt.internal.compiler.lookup.HelperInterfaceBinding;
import org.aspectj.ajdt.internal.compiler.lookup.InlineAccessFieldBinding;
+import org.aspectj.ajdt.internal.compiler.lookup.IntertypeMemberTypeFinder;
import org.aspectj.ajdt.internal.compiler.lookup.PrivilegedHandler;
import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
@@ -47,10 +48,13 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBin
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TagBits;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding;
import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.AjcMemberMaker;
import org.aspectj.weaver.NameMangler;
+import org.aspectj.weaver.NewMemberClassTypeMunger;
import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedType;
@@ -63,8 +67,12 @@ import org.aspectj.weaver.patterns.PerFromSuper;
import org.aspectj.weaver.patterns.PerSingleton;
import org.aspectj.weaver.patterns.TypePattern;
-// (we used to...) making all aspects member types avoids a nasty hierarchy pain
-// switched from MemberTypeDeclaration to TypeDeclaration
+/**
+ * Represents an aspect declaration.
+ *
+ * @author PARC
+ * @author Andy Clement
+ */
public class AspectDeclaration extends TypeDeclaration {
// public IAjDeclaration[] ajDeclarations;
@@ -73,25 +81,19 @@ public class AspectDeclaration extends TypeDeclaration {
public ResolvedMember aspectOfMethod;
public ResolvedMember ptwGetWithinTypeNameMethod;
public ResolvedMember hasAspectMethod;
-
- public Map accessForInline = new HashMap();
- public Map superAccessForInline = new HashMap();
-
+ public Map<ResolvedMember, Binding> accessForInline = new HashMap<ResolvedMember, Binding>();
+ public Map<ResolvedMember, AccessForInlineVisitor.SuperAccessMethodPair> superAccessForInline = new HashMap<ResolvedMember, AccessForInlineVisitor.SuperAccessMethodPair>();
public boolean isPrivileged;
- private int declaredModifiers;
-
public EclipseSourceType concreteName;
-
public ReferenceType typeX;
-
public EclipseFactory factory; // ??? should use this consistently
-
public int adviceCounter = 1; // Used as a part of the generated name for advice methods
public int declareCounter = 1; // Used as a part of the generated name for methods representing declares
-
// for better error messages in 1.0 to 1.1 transition
public TypePattern dominatesPattern;
+ private int declaredModifiers;
+
public AspectDeclaration(CompilationResult compilationResult) {
super(compilationResult);
// perClause = new PerSingleton();
@@ -322,6 +324,7 @@ public class AspectDeclaration extends TypeDeclaration {
/**
* A pointcut might have already added the attribute, let's not add it again.
*/
+ @SuppressWarnings("unchecked")
private void addVersionAttributeIfNecessary(ClassFile classFile) {
for (Iterator iter = classFile.extraAttributes.iterator(); iter.hasNext();) {
EclipseAttributeAdapter element = (EclipseAttributeAdapter) iter.next();
@@ -335,13 +338,13 @@ public class AspectDeclaration extends TypeDeclaration {
private static char[] weaverVersionChars = "org.aspectj.weaver.WeaverVersion".toCharArray();
private void generateInlineAccessMembers(ClassFile classFile) {
- for (Iterator i = superAccessForInline.values().iterator(); i.hasNext();) {
- AccessForInlineVisitor.SuperAccessMethodPair pair = (AccessForInlineVisitor.SuperAccessMethodPair) i.next();
+ for (Iterator<SuperAccessMethodPair> i = superAccessForInline.values().iterator(); i.hasNext();) {
+ AccessForInlineVisitor.SuperAccessMethodPair pair = i.next();
generateSuperAccessMethod(classFile, pair.accessMethod, pair.originalMethod);
}
- for (Iterator i = accessForInline.entrySet().iterator(); i.hasNext();) {
- Map.Entry e = (Map.Entry) i.next();
- generateInlineAccessMethod(classFile, (Binding) e.getValue(), (ResolvedMember) e.getKey());
+ for (Iterator<Map.Entry<ResolvedMember, Binding>> i = accessForInline.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<ResolvedMember, Binding> e = i.next();
+ generateInlineAccessMethod(classFile, e.getValue(), e.getKey());
}
}
@@ -402,8 +405,8 @@ public class AspectDeclaration extends TypeDeclaration {
generateMethod(classFile, methodBinding, null, gen);
}
- protected List makeEffectiveSignatureAttribute(ResolvedMember sig, Shadow.Kind kind, boolean weaveBody) {
- List l = new ArrayList(1);
+ protected List<EclipseAttributeAdapter> makeEffectiveSignatureAttribute(ResolvedMember sig, Shadow.Kind kind, boolean weaveBody) {
+ List<EclipseAttributeAdapter> l = new ArrayList<EclipseAttributeAdapter>(1);
l.add(new EclipseAttributeAdapter(new AjAttribute.EffectiveSignatureAttribute(sig, kind, weaveBody)));
return l;
}
@@ -415,10 +418,7 @@ public class AspectDeclaration extends TypeDeclaration {
* methods are able to masquerade as any join point (a field set, field get or method call). The effective signature attribute
* is 'unwrapped' in BcelClassWeaver.matchInvokeInstruction()
*/
- private void generateMethod(ClassFile classFile, MethodBinding methodBinding, List additionalAttributes/*
- * ResolvedMember
- * realMember
- */, BodyGenerator gen) {
+ private void generateMethod(ClassFile classFile, MethodBinding methodBinding, List additionalAttributes, BodyGenerator gen) {
// EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope);
classFile.generateMethodInfoHeader(methodBinding);
int methodAttributeOffset = classFile.contentsOffset;
@@ -1032,6 +1032,21 @@ public class AspectDeclaration extends TypeDeclaration {
return perClause;
}
+ public void processIntertypeMemberTypes(ClassScope classScope) {
+ factory = EclipseFactory.fromScopeLookupEnvironment(scope);
+ if (memberTypes != null) {
+ for (int i = 0; i < memberTypes.length; i++) {
+ if (memberTypes[i] instanceof IntertypeMemberClassDeclaration) {
+ EclipseTypeMunger m = ((IntertypeMemberClassDeclaration) memberTypes[i]).build(classScope);
+ if (m != null) {
+ mungeNewInnerClass(m, factory);
+ concreteName.typeMungers.add(m);
+ }
+ }
+ }
+ }
+ }
+
public void buildInterTypeAndPerClause(ClassScope classScope) {
factory = EclipseFactory.fromScopeLookupEnvironment(scope);
if (isPrivileged) {
@@ -1060,16 +1075,6 @@ public class AspectDeclaration extends TypeDeclaration {
}
}
}
- if (memberTypes != null) {
- for (int i = 0; i < memberTypes.length; i++) {
- if (memberTypes[i] instanceof IntertypeMemberClassDeclaration) {
- EclipseTypeMunger m = ((IntertypeMemberClassDeclaration) memberTypes[i]).build(classScope);
- if (m != null) {
- concreteName.typeMungers.add(m);
- }
- }
- }
- }
concreteName.getDeclaredPointcuts();
}
@@ -1110,6 +1115,61 @@ public class AspectDeclaration extends TypeDeclaration {
// return s;
// }
+ // very similar to code in EclipseTypeMunger
+ private void mungeNewInnerClass(EclipseTypeMunger m, EclipseFactory world) {
+
+ NewMemberClassTypeMunger munger = (NewMemberClassTypeMunger) m.getMunger();
+
+ // private boolean mungeNewInnerClass(SourceTypeBinding sourceType, ResolvedType onType, NewMemberClassTypeMunger munger,
+ // boolean isExactTargetType) {
+
+ SourceTypeBinding aspectTypeBinding = (SourceTypeBinding) world.makeTypeBinding(m.getAspectType());
+
+ char[] mungerMemberTypeName = ("$" + munger.getMemberTypeName()).toCharArray();
+ ReferenceBinding innerTypeBinding = null;
+ for (ReferenceBinding innerType : aspectTypeBinding.memberTypes) {
+ char[] compounded = CharOperation.concatWith(innerType.compoundName, '.');
+ if (org.aspectj.org.eclipse.jdt.core.compiler.CharOperation.endsWith(compounded, mungerMemberTypeName)) {
+ innerTypeBinding = innerType;
+ break;
+ }
+ }
+ // may be unresolved if the aspect type binding was a BinaryTypeBinding
+ if (innerTypeBinding instanceof UnresolvedReferenceBinding) {
+ innerTypeBinding = BinaryTypeBinding.resolveType(innerTypeBinding, world.getLookupEnvironment(), true);
+ }
+ if (innerTypeBinding == null) {
+ throw new IllegalStateException("Could not find inner type binding for '" + munger.getMemberTypeName() + "'");
+ }
+
+ // TODO adjust modifier?
+ // TODO deal with itd of it onto an interface
+
+ SourceTypeBinding targetSourceTypeBinding = (SourceTypeBinding) world.makeTypeBinding(munger.getTargetType());
+ ReferenceBinding[] existingMemberTypes = targetSourceTypeBinding.memberTypes();
+ for (int i = 0; i < existingMemberTypes.length; i++) {
+ char[] compounded = CharOperation.concatWith(existingMemberTypes[i].compoundName, '.');
+ if (CharOperation.endsWith(compounded, mungerMemberTypeName)) {
+ scope.problemReporter().signalError(sourceStart(), sourceEnd(),
+ "target type already declares a member type with the name '" + munger.getMemberTypeName() + "'");
+ return;
+ }
+ }
+
+ findOrCreateInterTypeMemberClassFinder(targetSourceTypeBinding).addInterTypeMemberType(innerTypeBinding);
+ }
+
+ private IntertypeMemberTypeFinder findOrCreateInterTypeMemberClassFinder(SourceTypeBinding sourceType) {
+ IntertypeMemberTypeFinder finder = (IntertypeMemberTypeFinder) sourceType.typeFinder;
+ if (finder == null) {
+ finder = new IntertypeMemberTypeFinder();
+ sourceType.typeFinder = finder;
+ finder.targetTypeBinding = sourceType;
+ sourceType.tagBits &= ~TagBits.HasNoMemberTypes; // ensure it thinks it has one
+ }
+ return finder;
+ }
+
public StringBuffer printHeader(int indent, StringBuffer output) {
// since all aspects are made public we want to print the
// modifiers that were supplied in the original source code
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
index 855e8f736..e38bfdd85 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
@@ -62,6 +62,7 @@ import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ReferenceTypeDelegate;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.ResolvedTypeMunger;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.WeaverMessages;
import org.aspectj.weaver.WeaverStateInfo;
@@ -88,7 +89,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
public EclipseFactory factory = null;
// private boolean builtInterTypesAndPerClauses = false;
- private final List pendingTypesToWeave = new ArrayList();
+ private final List<SourceTypeBinding> pendingTypesToWeave = new ArrayList<SourceTypeBinding>();
// Q: What are dangerousInterfaces?
// A: An interface is considered dangerous if an ITD has been made upon it
@@ -175,28 +176,39 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
// need to build inter-type declarations for all AspectDeclarations at
// this point
// this MUST be done in order from super-types to subtypes
- List typesToProcess = new ArrayList();
+ List<SourceTypeBinding> typesToProcess = new ArrayList<SourceTypeBinding>();
+ List<SourceTypeBinding> aspectsToProcess = new ArrayList<SourceTypeBinding>();
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
CompilationUnitScope cus = units[i].scope;
SourceTypeBinding[] stbs = cus.topLevelTypes;
for (int j = 0; j < stbs.length; j++) {
SourceTypeBinding stb = stbs[j];
typesToProcess.add(stb);
+ TypeDeclaration typeDeclaration = stb.scope.referenceContext;
+ if (typeDeclaration instanceof AspectDeclaration) {
+ aspectsToProcess.add(stb);
+ }
}
}
factory.getWorld().getCrosscuttingMembersSet().reset();
+
+ // Need to do these before the other ITDs
+ for (SourceTypeBinding aspectToProcess : aspectsToProcess) {
+ processInterTypeMemberTypes(aspectToProcess.scope);
+ }
+
while (typesToProcess.size() > 0) {
// removes types from the list as they are processed...
- collectAllITDsAndDeclares((SourceTypeBinding) typesToProcess.get(0), typesToProcess);
+ collectAllITDsAndDeclares(typesToProcess.get(0), typesToProcess);
}
factory.finishTypeMungers();
// now do weaving
- Collection typeMungers = factory.getTypeMungers();
+ List<ConcreteTypeMunger> typeMungers = factory.getTypeMungers();
- Collection declareParents = factory.getDeclareParents();
- Collection declareAnnotationOnTypes = factory.getDeclareAnnotationOnTypes();
+ List<DeclareParents> declareParents = factory.getDeclareParents();
+ List<DeclareAnnotation> declareAnnotationOnTypes = factory.getDeclareAnnotationOnTypes();
doPendingWeaves();
@@ -238,15 +250,12 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
while (typesToProcess.size() > 0) {
// A side effect of weaveIntertypes() is that the processed type
// is removed from the collection
- weaveIntertypes(typesToProcess, (SourceTypeBinding) typesToProcess.get(0), typeMungers, declareParents,
- declareAnnotationOnTypes);
+ weaveIntertypes(typesToProcess, typesToProcess.get(0), typeMungers, declareParents, declareAnnotationOnTypes);
}
} else {
// Order isn't important
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
- // System.err.println("Working on "+new
- // String(units[i].getFileName()));
weaveInterTypeDeclarations(units[i].scope, typeMungers, declareParents, declareAnnotationOnTypes);
}
}
@@ -375,8 +384,9 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
* problems if you supply 'pieces' of a hierarchy, i.e. the bottom and the top, but not the middle - but what the hell are you
* doing if you do that?
*/
- private void weaveIntertypes(List typesToProcess, SourceTypeBinding typeToWeave, Collection typeMungers,
- Collection declareParents, Collection declareAnnotationOnTypes) {
+ private void weaveIntertypes(List<SourceTypeBinding> typesToProcess, SourceTypeBinding typeToWeave,
+ List<ConcreteTypeMunger> typeMungers, List<DeclareParents> declareParents,
+ List<DeclareAnnotation> declareAnnotationOnTypes) {
// Look at the supertype first
ReferenceBinding superType = typeToWeave.superclass();
if (typesToProcess.contains(superType) && superType instanceof SourceTypeBinding) {
@@ -493,6 +503,18 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
return couldBeAtAspect;
}
+ /**
+ * Applies any intertype member type declarations up front.
+ */
+ private void processInterTypeMemberTypes(ClassScope classScope) {
+ TypeDeclaration dec = classScope.referenceContext;
+ if (dec instanceof AspectDeclaration) {
+ ((AspectDeclaration) dec).processIntertypeMemberTypes(classScope);
+ }
+ // if we are going to support nested aspects making itd member types, copy the logic from the end of
+ // buildInterTypeAndPerClause() which walks members
+ }
+
private void buildInterTypeAndPerClause(ClassScope s) {
TypeDeclaration dec = s.referenceContext;
if (dec instanceof AspectDeclaration) {
@@ -554,8 +576,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
return false;
}
- private void weaveInterTypeDeclarations(CompilationUnitScope unit, Collection typeMungers, Collection declareParents,
- Collection declareAnnotationOnTypes) {
+ private void weaveInterTypeDeclarations(CompilationUnitScope unit, List<ConcreteTypeMunger> typeMungers,
+ List<DeclareParents> declareParents, List<DeclareAnnotation> declareAnnotationOnTypes) {
for (int i = 0, length = unit.topLevelTypes.length; i < length; i++) {
weaveInterTypeDeclarations(unit.topLevelTypes[i], typeMungers, declareParents, declareAnnotationOnTypes, false);
}
@@ -565,6 +587,50 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
if (!factory.areTypeMungersFinished()) {
if (!pendingTypesToWeave.contains(sourceType)) {
pendingTypesToWeave.add(sourceType);
+
+// inner type ITD support - may need this for some incremental cases...
+ // List<ConcreteTypeMunger> ctms = factory.getWorld().getCrosscuttingMembersSet().getTypeMungersOfKind(
+ // ResolvedTypeMunger.InnerClass);
+ // // List<ConcreteTypeMunger> innerTypeMungers = new ArrayList<ConcreteTypeMunger>();
+ // // for (ConcreteTypeMunger ctm : ctms) {
+ // // if (ctm.getMunger() != null && ctm.getMunger().getKind() == ResolvedTypeMunger.InnerClass) {
+ // // innerTypeMungers.add(ctm);
+ // // }
+ // // }
+ // // that includes the innertype one...
+ // // doPendingWeaves at this level is about applying inner class
+ // BinaryTypeBinding t = (BinaryTypeBinding) sourceType;
+ // for (ConcreteTypeMunger ctm : innerTypeMungers) {
+ // NewMemberClassTypeMunger nmctm = (NewMemberClassTypeMunger) ctm.getMunger();
+ // ReferenceBinding[] rbs = t.memberTypes;
+ // UnresolvedType ut = factory.fromBinding(t);
+ // if (ut.equals(nmctm.getTargetType())) {
+ // // got a match here
+ // SourceTypeBinding aspectTypeBinding = (SourceTypeBinding) factory.makeTypeBinding(ctm.getAspectType());
+ //
+ // char[] mungerMemberTypeName = ("$" + nmctm.getMemberTypeName()).toCharArray();
+ // ReferenceBinding innerTypeBinding = null;
+ // for (ReferenceBinding innerType : aspectTypeBinding.memberTypes) {
+ // char[] compounded = CharOperation.concatWith(innerType.compoundName, '.');
+ // if (org.aspectj.org.eclipse.jdt.core.compiler.CharOperation.endsWith(compounded, mungerMemberTypeName)) {
+ // innerTypeBinding = innerType;
+ // break;
+ // }
+ // }
+ // // may be unresolved if the aspect type binding was a BinaryTypeBinding
+ // if (innerTypeBinding instanceof UnresolvedReferenceBinding) {
+ // innerTypeBinding = BinaryTypeBinding
+ // .resolveType(innerTypeBinding, factory.getLookupEnvironment(), true);
+ // }
+ // t.memberTypes(); // cause initialization
+ // t.memberTypes = new ReferenceBinding[] { innerTypeBinding };
+ //
+ // int stop = 1;
+ // // The inner type from the aspect should be put into the membertypebindings for this
+ //
+ // }
+ // }
+
}
} else {
weaveInterTypeDeclarations(sourceType, factory.getTypeMungers(), factory.getDeclareParents(), factory
@@ -572,8 +638,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
}
}
- private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, Collection typeMungers, Collection declareParents,
- Collection declareAnnotationOnTypes, boolean skipInners) {
+ private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, List<ConcreteTypeMunger> typeMungers,
+ List<DeclareParents> declareParents, List<DeclareAnnotation> declareAnnotationOnTypes, boolean skipInners) {
ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_INTERTYPE_DECLARATIONS,
sourceType.sourceName);
@@ -629,7 +695,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
// messages...
List decpToRepeat = new ArrayList();
- List decaToRepeat = new ArrayList();
+ List<DeclareAnnotation> decaToRepeat = new ArrayList<DeclareAnnotation>();
boolean anyNewParents = false;
boolean anyNewAnnotations = false;
@@ -656,11 +722,10 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
}
}
- for (Iterator i = declareAnnotationOnTypes.iterator(); i.hasNext();) {
- DeclareAnnotation deca = (DeclareAnnotation) i.next();
+ for (Iterator<DeclareAnnotation> i = declareAnnotationOnTypes.iterator(); i.hasNext();) {
+ DeclareAnnotation deca = i.next();
boolean didSomething = doDeclareAnnotations(deca, sourceType, true);
if (didSomething) {
-
anyNewAnnotations = true;
} else {
if (!deca.getTypePattern().isStar()) {
@@ -701,7 +766,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
decaToRepeat.removeAll(forRemoval);
}
- for (Iterator i = typeMungers.iterator(); i.hasNext();) {
+ for (Iterator<ConcreteTypeMunger> i = typeMungers.iterator(); i.hasNext();) {
EclipseTypeMunger munger = (EclipseTypeMunger) i.next();
if (munger.matches(onType)) {
if (needOldStyleWarning) {
@@ -710,15 +775,27 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
needOldStyleWarning = false;
}
onType.addInterTypeMunger(munger, true);
+ if (munger.getMunger()!=null && munger.getMunger().getKind() == ResolvedTypeMunger.InnerClass) {
+ // Must do these right now, because if we do an ITD member afterwards it may attempt to reference the
+ // type being applied (the call above 'addInterTypeMunger' will fail for these ITDs if it needed
+ // it to be in place)
+ if (munger.munge(sourceType, onType)) {
+ if (factory.pushinCollector != null) {
+ factory.pushinCollector.tagAsMunged(sourceType, munger.getSourceMethod());
+ }
+ }
+ }
}
}
onType.checkInterTypeMungers();
for (Iterator i = onType.getInterTypeMungers().iterator(); i.hasNext();) {
EclipseTypeMunger munger = (EclipseTypeMunger) i.next();
- if (munger.munge(sourceType, onType)) {
- if (factory.pushinCollector != null) {
- factory.pushinCollector.tagAsMunged(sourceType, munger.getSourceMethod());
+ if (munger.getMunger()==null || munger.getMunger().getKind() != ResolvedTypeMunger.InnerClass) {
+ if (munger.munge(sourceType, onType)) {
+ if (factory.pushinCollector != null) {
+ factory.pushinCollector.tagAsMunged(sourceType, munger.getSourceMethod());
+ }
}
}
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java
index 55bfe470f..36ee073b6 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseTypeMunger.java
@@ -165,6 +165,7 @@ public class EclipseTypeMunger extends ConcreteTypeMunger {
return true;
}
+ // very similar to code in AspectDeclaration
private boolean mungeNewInnerClass(SourceTypeBinding sourceType, ResolvedType onType, NewMemberClassTypeMunger munger,
boolean isExactTargetType) {
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberClassBinding.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberClassBinding.java
deleted file mode 100644
index 92dda50f9..000000000
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeMemberClassBinding.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2010 Contributors
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andy Clement - SpringSource
- * ******************************************************************/
-package org.aspectj.ajdt.internal.compiler.lookup;
-
-import org.aspectj.asm.internal.CharOperation;
-import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MemberTypeBinding;
-import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.aspectj.weaver.NewMemberClassTypeMunger;
-import org.aspectj.weaver.ResolvedType;
-
-/**
- * A special kind of MemberTypeBinding that is targeting some other type.
- *
- * @author Andy Clement
- */
-public class InterTypeMemberClassBinding extends MemberTypeBinding {
-
- public InterTypeMemberClassBinding(EclipseFactory world, NewMemberClassTypeMunger munger, ResolvedType aspectType,
- ResolvedType onType, String name, SourceTypeBinding sourceTypeOnType) {
- super(toCompoundName(onType, name), sourceTypeOnType.scope, sourceTypeOnType);
- SourceTypeBinding stb = (SourceTypeBinding) world.makeTypeBinding(aspectType);
- ReferenceBinding found = null;
- for (int i = 0; i < stb.memberTypes.length; i++) {
- ReferenceBinding rb = stb.memberTypes[i];
- char[] sn = rb.sourceName;
- if (CharOperation.equals(name.toCharArray(), sn)) {
- found = rb;
- }
- }
-
- if (found == null) {
- throw new IllegalStateException();
- }
- FieldBinding[] fbs = found.fields();
- this.fields = new FieldBinding[fbs.length];
- int fCounter = 0;
- for (FieldBinding fb : fbs) {
- this.fields[fCounter++] = new FieldBinding(fb, this);
- }
- // world.makeTypeBinding(onType));
- // helper interface binding is perhaps a good example of a 'new binding'
- // this.fPackage = enclosingType.fPackage;
- // //this.fileName = scope.referenceCompilationUnit().getFileName();
- // this.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccInterface | ClassFileConstants.AccAbstract;
- // this.sourceName = enclosingType.scope.referenceContext.name;
- // this.enclosingType = enclosingType;
- // this.typeX = typeX;
- this.typeVariables = Binding.NO_TYPE_VARIABLES;
- this.memberTypes = Binding.NO_MEMBER_TYPES;
- // this.scope =enclosingType.scope;
- // this.superInterfaces = new ReferenceBinding[0];
- }
-
- private static char[][] toCompoundName(ResolvedType onType, String name) {
- String memberName = onType.getName() + "$" + name;
- return CharOperation.splitOn('.', memberName.toCharArray());
- }
-}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/IntertypeMemberTypeFinder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/IntertypeMemberTypeFinder.java
index 9b86a99c7..0bcac22d2 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/IntertypeMemberTypeFinder.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/IntertypeMemberTypeFinder.java
@@ -11,8 +11,8 @@
* ******************************************************************/
package org.aspectj.ajdt.internal.compiler.lookup;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ITypeFinder;
@@ -32,7 +32,7 @@ public class IntertypeMemberTypeFinder implements ITypeFinder {
public SourceTypeBinding targetTypeBinding;
// The new types declared onto the target
- private List<ReferenceBinding> intertypeMemberTypes = new ArrayList<ReferenceBinding>();
+ private Set<ReferenceBinding> intertypeMemberTypes = new HashSet<ReferenceBinding>();
public void addInterTypeMemberType(ReferenceBinding binding) {
intertypeMemberTypes.add(binding);