diff options
author | Andy Clement <andrew.clement@gmail.com> | 2013-05-31 23:07:29 -0700 |
---|---|---|
committer | Andy Clement <andrew.clement@gmail.com> | 2013-05-31 23:07:29 -0700 |
commit | 31d8e259e5cd8b1b4810d69bbf4b9ea45ae4a4c8 (patch) | |
tree | 4a273bd73d75a264bbca01cdffbf7a3c9dc1fd57 /org.aspectj.matcher | |
parent | 6f4140ac7028b9074e694e4c0b9de8b05e4b048a (diff) | |
download | aspectj-31d8e259e5cd8b1b4810d69bbf4b9ea45ae4a4c8.tar.gz aspectj-31d8e259e5cd8b1b4810d69bbf4b9ea45ae4a4c8.zip |
Use class file attributes to find containing class
https://bugs.eclipse.org/bugs/show_bug.cgi?id=407494
Diffstat (limited to 'org.aspectj.matcher')
3 files changed, 17 insertions, 25 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java index 31f770da6..9746fea81 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java @@ -914,6 +914,10 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl return false; } + public ResolvedType getOuterClass() { + return null; + } + public void addAnnotation(AnnotationAJ annotationX) { throw new RuntimeException("ResolvedType.addAnnotation() should never be called"); } @@ -1503,20 +1507,14 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl * given in JLS 13.1, where it guarantees that if you call getDeclaringType() repeatedly, you will eventually get the top-level * class, but it does not say anything about classes in between. * - * @return the declaring UnresolvedType object, or null. + * @return the declaring type, or null if it is not an nested type. */ public ResolvedType getDeclaringType() { if (isArray()) { return null; } - String name = getName(); - int lastDollar = name.lastIndexOf('$'); - while (lastDollar > 0) { // allow for classes starting '$' (pr120474) - ResolvedType ret = world.resolve(UnresolvedType.forName(name.substring(0, lastDollar)), true); - if (!ResolvedType.isMissing(ret)) { - return ret; - } - lastDollar = name.lastIndexOf('$', lastDollar - 1); + if (isNested() || isAnonymous()) { + return getOuterClass(); } return null; } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java index 6888ff2f7..6e74a1a2f 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ReferencePointcut.java @@ -124,7 +124,7 @@ public class ReferencePointcut extends Pointcut { public void resolveBindings(IScope scope, Bindings bindings) { if (onTypeSymbolic != null) { onType = onTypeSymbolic.resolveExactType(scope, bindings); - // in this case we've already signalled an error + // in this case we've already signaled an error if (ResolvedType.isMissing(onType)) { return; } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java b/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java index 5b605ef96..3a7e31d6f 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegate.java @@ -48,7 +48,7 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega protected Class myClass = null; protected WeakClassLoaderReference classLoaderReference = null; - private World world; + protected World world; private ReferenceType resolvedType; private ResolvedMember[] fields = null; private ResolvedMember[] methods = null; @@ -150,23 +150,19 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega } public boolean isAnonymous() { - return false; + // this isn't in < Java 1.5 but I think we are moving beyond the need to support those levels + return this.myClass.isAnonymousClass(); } public boolean isNested() { - // FIXME this is *wrong* but isMemberClass() doesnt exist in pre-1.5... - // (same deal as isAnonymous above...) - return true; - // boolean member = this.myClass.isMemberClass(); - // return member; + // this isn't in < Java 1.5 but I think we are moving beyond the need to support those levels + return this.myClass.isMemberClass(); } public ResolvedType getOuterClass() { - // FIXME getEnclosingClass() is Java5 ... dammit - // return - // ReflectionBasedReferenceTypeDelegateFactory.resolveTypeInWorld( - // myClass.getEnclosingClass(),world); - return null; + // this isn't in < Java 1.5 but I think we are moving beyond the need to support those levels + return ReflectionBasedReferenceTypeDelegateFactory.resolveTypeInWorld( + myClass.getEnclosingClass(),world); } /* @@ -308,9 +304,7 @@ public class ReflectionBasedReferenceTypeDelegate implements ReferenceTypeDelega return Collections.EMPTY_SET; } - /* - * (non-Javadoc) - * + /* * @see org.aspectj.weaver.ReferenceTypeDelegate#getTypeMungers() */ public Collection getTypeMungers() { |