summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-12-02 07:02:33 +0000
committeracolyer <acolyer>2005-12-02 07:02:33 +0000
commit99a8e7648584be91f418fb26714d25f402bfaff9 (patch)
treea7ea5942ab4444051b15c9c04878d5366772b447
parent5d7f95e4ce1074a11e0674ade94fe96807624165 (diff)
downloadaspectj-99a8e7648584be91f418fb26714d25f402bfaff9.tar.gz
aspectj-99a8e7648584be91f418fb26714d25f402bfaff9.zip
support for isNested, and use of that property when splitting names in WildTypePattern
-rw-r--r--weaver/src/org/aspectj/weaver/BoundedReferenceType.java4
-rw-r--r--weaver/src/org/aspectj/weaver/ReferenceType.java4
-rw-r--r--weaver/src/org/aspectj/weaver/ReferenceTypeDelegate.java1
-rw-r--r--weaver/src/org/aspectj/weaver/ResolvedType.java6
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java4
-rw-r--r--weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java32
-rw-r--r--weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java5
7 files changed, 44 insertions, 12 deletions
diff --git a/weaver/src/org/aspectj/weaver/BoundedReferenceType.java b/weaver/src/org/aspectj/weaver/BoundedReferenceType.java
index f2f7dac99..28d2e80d9 100644
--- a/weaver/src/org/aspectj/weaver/BoundedReferenceType.java
+++ b/weaver/src/org/aspectj/weaver/BoundedReferenceType.java
@@ -181,6 +181,10 @@ public class BoundedReferenceType extends ReferenceType {
return resolvedTypeX.isAnonymous();
}
+ public boolean isNested() {
+ return resolvedTypeX.isNested();
+ }
+
public String getRetentionPolicy() {
return resolvedTypeX.getRetentionPolicy();
}
diff --git a/weaver/src/org/aspectj/weaver/ReferenceType.java b/weaver/src/org/aspectj/weaver/ReferenceType.java
index eb2fa46f2..7cc34533a 100644
--- a/weaver/src/org/aspectj/weaver/ReferenceType.java
+++ b/weaver/src/org/aspectj/weaver/ReferenceType.java
@@ -166,6 +166,10 @@ public class ReferenceType extends ResolvedType {
return delegate.isAnonymous();
}
+ public boolean isNested() {
+ return delegate.isNested();
+ }
+
public String getRetentionPolicy() {
return delegate.getRetentionPolicy();
}
diff --git a/weaver/src/org/aspectj/weaver/ReferenceTypeDelegate.java b/weaver/src/org/aspectj/weaver/ReferenceTypeDelegate.java
index d00a4d288..101c06e66 100644
--- a/weaver/src/org/aspectj/weaver/ReferenceTypeDelegate.java
+++ b/weaver/src/org/aspectj/weaver/ReferenceTypeDelegate.java
@@ -38,6 +38,7 @@ public interface ReferenceTypeDelegate {
public boolean isClass();
public boolean isGeneric();
public boolean isAnonymous();
+ public boolean isNested();
public boolean isExposedToWeaver();
public boolean hasAnnotation(UnresolvedType ofType);
diff --git a/weaver/src/org/aspectj/weaver/ResolvedType.java b/weaver/src/org/aspectj/weaver/ResolvedType.java
index ba8d60a48..7ef50c857 100644
--- a/weaver/src/org/aspectj/weaver/ResolvedType.java
+++ b/weaver/src/org/aspectj/weaver/ResolvedType.java
@@ -54,7 +54,7 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
}
// ---- things that don't require a world
-
+
/**
* Returns an iterator through ResolvedType objects representing all the direct
* supertypes of this type. That is, through the superclass, if any, and
@@ -620,6 +620,10 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
return false;
}
+ public boolean isNested() {
+ return false;
+ }
+
/**
* Note: Only overridden by Name subtype
*/
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
index a6d499a9a..59dcea110 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
@@ -409,6 +409,10 @@ public class BcelObjectType extends AbstractReferenceTypeDelegate {
return javaClass.isAnonymous();
}
+ public boolean isNested() {
+ return javaClass.isNested();
+ }
+
public void addAnnotation(AnnotationX annotation) {
damaged = true;
// Add it to the set of annotations
diff --git a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
index 8313460bd..234bcc334 100644
--- a/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
+++ b/weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
@@ -200,12 +200,15 @@ public class WildTypePattern extends TypePattern {
}
//XXX inefficient implementation
- public static char[][] splitNames(String s) {
+ // we don't know whether $ characters are from nested types, or were
+ // part of the declared type name (generated code often uses $s in type
+ // names). More work required on our part to get this right...
+ public static char[][] splitNames(String s, boolean convertDollar) {
List ret = new ArrayList();
int startIndex = 0;
while (true) {
int breakIndex = s.indexOf('.', startIndex); // what about /
- if (breakIndex == -1) breakIndex = s.indexOf('$', startIndex); // we treat $ like . here
+ if (convertDollar && (breakIndex == -1)) breakIndex = s.indexOf('$', startIndex); // we treat $ like . here
if (breakIndex == -1) break;
char[] name = s.substring(startIndex, breakIndex).toCharArray();
ret.add(name);
@@ -230,7 +233,7 @@ public class WildTypePattern extends TypePattern {
// Ensure the annotation pattern is resolved
annotationPattern.resolve(type.getWorld());
- return matchesExactlyByName(targetTypeName,type.isAnonymous()) &&
+ return matchesExactlyByName(targetTypeName,type.isAnonymous(),type.isNested()) &&
matchesParameters(type,STATIC) &&
matchesBounds(type,STATIC) &&
annotationPattern.matches(annotatedType).alwaysTrue();
@@ -288,7 +291,7 @@ public class WildTypePattern extends TypePattern {
* @param targetTypeName
* @return
*/
- private boolean matchesExactlyByName(String targetTypeName, boolean isAnonymous) {
+ private boolean matchesExactlyByName(String targetTypeName, boolean isAnonymous, boolean isNested) {
// we deal with parameter matching separately...
if (targetTypeName.indexOf('<') != -1) {
targetTypeName = targetTypeName.substring(0,targetTypeName.indexOf('<'));
@@ -299,7 +302,7 @@ public class WildTypePattern extends TypePattern {
}
//XXX hack
if (knownMatches == null && importedPrefixes == null) {
- return innerMatchesExactly(targetTypeName,isAnonymous);
+ return innerMatchesExactly(targetTypeName,isAnonymous, isNested);
}
if (isNamePatternStar()) {
@@ -334,7 +337,7 @@ public class WildTypePattern extends TypePattern {
String knownPrefix = knownMatches[i] + "$";
if (targetTypeName.startsWith(knownPrefix)) {
int pos = lastIndexOfDotOrDollar(knownMatches[i]);
- if (innerMatchesExactly(targetTypeName.substring(pos+1),isAnonymous)) {
+ if (innerMatchesExactly(targetTypeName.substring(pos+1),isAnonymous,isNested)) {
return true;
}
}
@@ -349,13 +352,13 @@ public class WildTypePattern extends TypePattern {
//System.err.println("prefix match? " + prefix + " to " + targetTypeName);
if (targetTypeName.startsWith(prefix)) {
- if (innerMatchesExactly(targetTypeName.substring(prefix.length()),isAnonymous)) {
+ if (innerMatchesExactly(targetTypeName.substring(prefix.length()),isAnonymous,isNested)) {
return true;
}
}
}
- return innerMatchesExactly(targetTypeName,isAnonymous);
+ return innerMatchesExactly(targetTypeName,isAnonymous,isNested);
}
private int lastIndexOfDotOrDollar(String string) {
@@ -365,9 +368,9 @@ public class WildTypePattern extends TypePattern {
}
- private boolean innerMatchesExactly(String targetTypeName, boolean isAnonymous) {
+ private boolean innerMatchesExactly(String targetTypeName, boolean isAnonymous, boolean isNested) {
//??? doing this everytime is not very efficient
- char[][] names = splitNames(targetTypeName);
+ char[][] names = splitNames(targetTypeName,isNested);
return innerMatchesExactly(names, isAnonymous);
}
@@ -980,9 +983,16 @@ public class WildTypePattern extends TypePattern {
List ret = new ArrayList();
for (int i=0, len=possibleMatches.length; i < len; i++) {
- char[][] names = splitNames(possibleMatches[i]); //??? not most efficient
+ char[][] names = splitNames(possibleMatches[i],true); //??? not most efficient
if (namePatterns[0].matches(names[names.length-1])) {
ret.add(possibleMatches[i]);
+ continue;
+ }
+ if (possibleMatches[i].indexOf("$") != -1) {
+ names = splitNames(possibleMatches[i],false); //??? not most efficient
+ if (namePatterns[0].matches(names[names.length-1])) {
+ ret.add(possibleMatches[i]);
+ }
}
}
return (String[])ret.toArray(new String[ret.size()]);
diff --git a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java
index ef61c7f2f..cce85c323 100644
--- a/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java
+++ b/weaver/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java
@@ -156,6 +156,11 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega
public boolean isAnonymous() {
return false;
}
+
+ public boolean isNested() {
+ boolean member = this.myClass.isMemberClass();
+ return member;
+ }
/* (non-Javadoc)
* @see org.aspectj.weaver.ReferenceTypeDelegate#isExposedToWeaver()