summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Clement <andrew.clement@gmail.com>2012-09-06 09:38:34 -0700
committerAndy Clement <andrew.clement@gmail.com>2012-09-06 09:38:34 -0700
commit591a7e657dffbf63e11c4448e0555056bc295764 (patch)
tree8bdd993c0dada88de2926e31f02aa02444da8c4b
parentc2ff74fd569ea2ef0c4abdc06e3f36a77b1ddd2c (diff)
parenta847c704cd50e382dcd47cef44e8ebc1efc94ae2 (diff)
downloadaspectj-591a7e657dffbf63e11c4448e0555056bc295764.tar.gz
aspectj-591a7e657dffbf63e11c4448e0555056bc295764.zip
Merge branch 'master' of ssh://git.eclipse.org/gitroot/aspectj/org.aspectj
-rw-r--r--bridge/testsrc/org/aspectj/bridge/MessageTest.java18
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java73
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java6
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java5
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java14
-rw-r--r--org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java8
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java11
7 files changed, 78 insertions, 57 deletions
diff --git a/bridge/testsrc/org/aspectj/bridge/MessageTest.java b/bridge/testsrc/org/aspectj/bridge/MessageTest.java
index 19c5ee268..be30c48ba 100644
--- a/bridge/testsrc/org/aspectj/bridge/MessageTest.java
+++ b/bridge/testsrc/org/aspectj/bridge/MessageTest.java
@@ -46,12 +46,12 @@ public class MessageTest extends TestCase {
super(name);
}
- void checkListOrder(List list, Comparator c) { // XXX util
+ <T> void checkListOrder(List<T> list, Comparator<T> c) { // XXX util
assertNotNull(list);
assertNotNull(c);
- ListIterator it = list.listIterator();
- Object last = null;
- Object current = null;
+ ListIterator<T> it = list.listIterator();
+ T last = null;
+ T current = null;
while (it.hasNext()) {
current = it.next();
if (null != last) {
@@ -74,9 +74,9 @@ public class MessageTest extends TestCase {
public void testKind_isSameOrLessThan() {
IMessage.Kind last;
IMessage.Kind next = null;
- for (Iterator iter = IMessage.KINDS.iterator(); iter.hasNext();) {
+ for (Iterator<IMessage.Kind> iter = IMessage.KINDS.iterator(); iter.hasNext();) {
last = next;
- next = (IMessage.Kind) iter.next();
+ next = iter.next();
if (null == last) {
continue;
}
@@ -147,7 +147,7 @@ public class MessageTest extends TestCase {
String input = "input";
Throwable thrown = null;
ISourceLocation sl = null;
- Class exClass = null;
+ Class<?> exClass = null;
String descriptor = "Message"; // for make(...)
IMessage.Kind kind = IMessage.INFO;
@@ -203,7 +203,7 @@ public class MessageTest extends TestCase {
*/
protected void roundTrip(String input, IMessage.Kind kind,
Throwable thrown, ISourceLocation sourceLocation,
- String descriptor, Class exClass) {
+ String descriptor, Class<?> exClass) {
try {
IMessage m = make(input, kind, thrown, sourceLocation, descriptor);
if ((null == input) && (null != thrown)) {
@@ -251,7 +251,7 @@ class KindTest {
{ IMessage.ABORT, IMessage.DEBUG, IMessage.ERROR,
IMessage.INFO, IMessage.WARNING, IMessage.FAIL };
- static final List KINDLIST = Arrays.asList(KINDS);
+ static final List<IMessage.Kind> KINDLIST = Arrays.asList(KINDS);
/** used to clear instance BitSet */
static final BitSet UNSET = new BitSet(KINDS.length);
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 64f10059e..22e8fdf0d 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
@@ -426,8 +426,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
}
private void doPendingWeaves() {
- for (Iterator i = pendingTypesToWeave.iterator(); i.hasNext();) {
- SourceTypeBinding t = (SourceTypeBinding) i.next();
+ for (SourceTypeBinding t: pendingTypesToWeave) {
ContextToken tok = CompilationAndWeavingContext.enteringPhase(
CompilationAndWeavingContext.WEAVING_INTERTYPE_DECLARATIONS, t.sourceName);
weaveInterTypeDeclarations(t);
@@ -862,10 +861,10 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
* sourceType and onType are the 'same type' - the former is the 'Eclipse' version and the latter is the 'Weaver' version.
*/
private void processTypeMungersFromExistingWeaverState(SourceTypeBinding sourceType, ResolvedType onType) {
- Collection previouslyAppliedMungers = onType.getWeaverState().getTypeMungers(onType);
+ List<ConcreteTypeMunger> previouslyAppliedMungers = onType.getWeaverState().getTypeMungers(onType);
- for (Iterator i = previouslyAppliedMungers.iterator(); i.hasNext();) {
- ConcreteTypeMunger m = (ConcreteTypeMunger) i.next();
+ for (Iterator<ConcreteTypeMunger> i = previouslyAppliedMungers.iterator(); i.hasNext();) {
+ ConcreteTypeMunger m = i.next();
EclipseTypeMunger munger = factory.makeEclipseTypeMunger(m);
if (munger.munge(sourceType, onType)) {
if (onType.isInterface() && munger.getMunger().needsAccessToTopmostImplementor()) {
@@ -885,8 +884,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
ResolvedType resolvedSourceType = factory.fromEclipse(sourceType);
List<ResolvedType> newParents = declareParents.findMatchingNewParents(resolvedSourceType, false);
if (!newParents.isEmpty()) {
- for (Iterator i = newParents.iterator(); i.hasNext();) {
- ResolvedType parent = (ResolvedType) i.next();
+ for (Iterator<ResolvedType> i = newParents.iterator(); i.hasNext();) {
+ ResolvedType parent = i.next();
if (dangerousInterfaces.containsKey(parent)) {
ResolvedType onType = factory.fromEclipse(sourceType);
factory.showMessage(IMessage.ERROR, onType + ": " + dangerousInterfaces.get(parent),
@@ -919,7 +918,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
if ((bits & TagBits.AnnotationTargetMASK) == 0) {
return "";
}
- Set s = new HashSet();
+ Set<String> s = new HashSet<String>();
if ((bits & TagBits.AnnotationForAnnotationType) != 0) {
s.add("ANNOTATION_TYPE");
}
@@ -946,8 +945,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
}
StringBuffer sb = new StringBuffer();
sb.append("{");
- for (Iterator iter = s.iterator(); iter.hasNext();) {
- String element = (String) iter.next();
+ for (Iterator<String> iter = s.iterator(); iter.hasNext();) {
+ String element = iter.next();
sb.append(element);
if (iter.hasNext()) {
sb.append(",");
@@ -1288,33 +1287,33 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC
return (abits & (TagBits.AnnotationForAnnotationType | TagBits.AnnotationForType)) == 0;
}
- private void reportDeclareParentsMessage(WeaveMessage.WeaveMessageKind wmk, SourceTypeBinding sourceType, ResolvedType parent) {
- if (!factory.getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) {
- String filename = new String(sourceType.getFileName());
-
- int takefrom = filename.lastIndexOf('/');
- if (takefrom == -1) {
- takefrom = filename.lastIndexOf('\\');
- }
- filename = filename.substring(takefrom + 1);
-
- factory.getWorld()
- .getMessageHandler()
- .handleMessage(
- WeaveMessage.constructWeavingMessage(wmk,
- new String[] { CharOperation.toString(sourceType.compoundName), filename,
- parent.getClassName(),
- getShortname(parent.getSourceLocation().getSourceFile().getPath()) }));
- }
- }
-
- private String getShortname(String path) {
- int takefrom = path.lastIndexOf('/');
- if (takefrom == -1) {
- takefrom = path.lastIndexOf('\\');
- }
- return path.substring(takefrom + 1);
- }
+// private void reportDeclareParentsMessage(WeaveMessage.WeaveMessageKind wmk, SourceTypeBinding sourceType, ResolvedType parent) {
+// if (!factory.getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) {
+// String filename = new String(sourceType.getFileName());
+//
+// int takefrom = filename.lastIndexOf('/');
+// if (takefrom == -1) {
+// takefrom = filename.lastIndexOf('\\');
+// }
+// filename = filename.substring(takefrom + 1);
+//
+// factory.getWorld()
+// .getMessageHandler()
+// .handleMessage(
+// WeaveMessage.constructWeavingMessage(wmk,
+// new String[] { CharOperation.toString(sourceType.compoundName), filename,
+// parent.getClassName(),
+// getShortname(parent.getSourceLocation().getSourceFile().getPath()) }));
+// }
+// }
+
+// private String getShortname(String path) {
+// int takefrom = path.lastIndexOf('/');
+// if (takefrom == -1) {
+// takefrom = path.lastIndexOf('\\');
+// }
+// return path.substring(takefrom + 1);
+// }
private void addParent(SourceTypeBinding sourceType, ResolvedType parent) {
ReferenceBinding parentBinding = (ReferenceBinding) factory.makeTypeBinding(parent);
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
index 154746fa4..14f667a2b 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
@@ -482,6 +482,12 @@ public class EclipseFactory {
}
}
}
+ for (ConcreteTypeMunger ctm: ret) {
+ ResolvedMember rm = ctm.getSignature();
+ if (rm!=null) {
+ rm.resolve(this.getWorld());
+ }
+ }
finishedTypeMungers = ret;
}
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java
index 0f82f045f..6ddf51bb5 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedMemberImpl.java
@@ -30,6 +30,7 @@ import org.aspectj.bridge.ISourceLocation;
public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, ResolvedMember {
private String[] parameterNames = null;
+ private boolean isResolved = false;
protected UnresolvedType[] checkedExceptions = UnresolvedType.NONE;
/**
@@ -568,6 +569,9 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Reso
// something different to world.resolve(member)
@Override
public ResolvedMember resolve(World world) {
+ if (isResolved) {
+ return this;
+ }
// make sure all the pieces of a resolvedmember really are resolved
try {
if (typeVariables != null && typeVariables.length > 0) {
@@ -601,6 +605,7 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Reso
} finally {
world.setTypeVariableLookupScope(null);
}
+ isResolved = true;
return this;
}
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
index ace82bca5..b9fe12a3e 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
@@ -1977,8 +1977,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
* an additional source location.
*/
public boolean checkLegalOverride(ResolvedMember parent, ResolvedMember child, int transformerPosition, ResolvedType aspectType) {
- // System.err.println("check: " + child.getDeclaringType() +
- // " overrides " + parent.getDeclaringType());
+ // System.err.println("check: " + child.getDeclaringType() + " overrides " + parent.getDeclaringType());
if (Modifier.isFinal(parent.getModifiers())) {
// If the ITD matching is occurring due to pulling in a BinaryTypeBinding then this check can incorrectly
// signal an error because the ITD transformer being examined here will exactly match the member it added
@@ -1993,10 +1992,8 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
List<ConcreteTypeMunger> transformersOnThisType = wsi.getTypeMungers(nonItdDeclaringType);
if (transformersOnThisType != null) {
for (ConcreteTypeMunger transformer : transformersOnThisType) {
- // relatively crude check - is the ITD
- // for the same as the existingmember
- // and does it come
- // from the same aspect
+ // relatively crude check - is the ITD for the same as the existingmember
+ // and does it come from the same aspect
if (transformer.aspectType.equals(aspectType)) {
if (parent.equalsApartFromDeclaringType(transformer.getSignature())) {
return true;
@@ -2027,7 +2024,10 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
// !rtParentReturnType.isAssignableFrom(rtChildReturnType);
// }
} else {
- incompatibleReturnTypes = !parent.getReturnType().equals(child.getReturnType());
+ ResolvedType rtParentReturnType = parent.resolve(world).getGenericReturnType().resolve(world);
+ ResolvedType rtChildReturnType = child.resolve(world).getGenericReturnType().resolve(world);
+
+ incompatibleReturnTypes = !rtParentReturnType.equals(rtChildReturnType);
}
if (incompatibleReturnTypes) {
diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java
index 902e41c24..7ffad81d5 100644
--- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java
+++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java
@@ -698,13 +698,13 @@ public class ParserTestCase extends PatternsTestCase {
fail("Expected WildAnnotationTypePattern but was " + atp.getClass());
}
WildAnnotationTypePattern watp = (WildAnnotationTypePattern) atp;
- Map m = watp.annotationValues;
- Set keys = m.keySet();
- List orderedKeys = new ArrayList();
+ Map<String,String> m = watp.annotationValues;
+ Set<String> keys = m.keySet();
+ List<String> orderedKeys = new ArrayList<String>();
orderedKeys.addAll(keys);
Collections.sort(orderedKeys);
StringBuffer sb = new StringBuffer();
- for (Iterator iterator = orderedKeys.iterator(); iterator.hasNext();) {
+ for (Iterator<String> iterator = orderedKeys.iterator(); iterator.hasNext();) {
String object = (String) iterator.next();
sb.append(object).append("=").append(m.get(object));
if (iterator.hasNext()) {
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
index d65e03787..adc1e8a84 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
@@ -1931,6 +1931,17 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
fg.addAnnotation(ag);
}
}
+
+ if (weaver.getWorld().isInJava5Mode()) {
+ String basicSignature = field.getSignature();
+ String genericSignature = field.getReturnType().resolve(weaver.getWorld()).getSignatureForAttribute();
+ // String genericSignature =
+ // ((ResolvedMemberImpl)field).getSignatureForAttribute();
+ if (!basicSignature.equals(genericSignature)) {
+ // Add a signature attribute to it
+ fg.addAttribute(createSignatureAttribute(gen.getConstantPool(), genericSignature));
+ }
+ }
gen.addField(fg, getSourceLocation());
}
// this uses a shadow munger to add init method to constructors