public boolean isNested() {
return ((declaration.modifiers & ASTNode.IsMemberTypeMASK) != 0);
}
+
+ public ResolvedType getOuterClass() {
+ if (declaration.enclosingType==null) return null;
+ return eclipseWorld().fromEclipse(declaration.enclosingType.binding);
+ }
public boolean isAnnotationStyleAspect() {
if (declaration.annotations == null) {
import java.util.Iterator;
import java.util.List;
+import org.aspectj.apache.bcel.classfile.GenericSignatureParser;
+import org.aspectj.apache.bcel.classfile.Signature;
+import org.aspectj.apache.bcel.classfile.Signature.ClassSignature;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.weaver.patterns.Declare;
protected boolean exposedToWeaver;
protected ReferenceType resolvedTypeX;
private ISourceContext sourceContext = SourceContextImpl.UNKNOWN_SOURCE_CONTEXT;
+ protected ClassSignature cachedGenericClassTypeSignature;
public AbstractReferenceTypeDelegate(ReferenceType resolvedTypeX, boolean exposedToWeaver) {
this.resolvedTypeX = resolvedTypeX;
this.sourceContext = isc;
}
+ public Signature.ClassSignature getGenericClassTypeSignature() {
+ if (cachedGenericClassTypeSignature==null) {
+ String sig = getDeclaredGenericSignature();
+ if (sig!=null) {
+ GenericSignatureParser parser = new GenericSignatureParser();
+ cachedGenericClassTypeSignature = parser.parseAsClassSignature(sig);
+ }
+ }
+ return cachedGenericClassTypeSignature;
+ }
+
+ protected Signature.FormalTypeParameter[] getFormalTypeParametersFromOuterClass() {
+ List typeParameters = new ArrayList();
+ ReferenceType outer = (ReferenceType)getOuterClass();
+ ReferenceTypeDelegate outerDelegate = outer.getDelegate();
+ AbstractReferenceTypeDelegate outerObjectType = (AbstractReferenceTypeDelegate) outerDelegate;
+ if (outerObjectType.isNested()) {
+ Signature.FormalTypeParameter[] parentParams = outerObjectType.getFormalTypeParametersFromOuterClass();
+ for (int i = 0; i < parentParams.length; i++) {
+ typeParameters.add(parentParams[i]);
+ }
+ }
+ Signature.ClassSignature outerSig = outerObjectType.getGenericClassTypeSignature();
+ if (outerSig != null) {
+ for (int i = 0; i < outerSig.formalTypeParameters .length; i++) {
+ typeParameters.add(outerSig.formalTypeParameters[i]);
+ }
+ }
+
+ Signature.FormalTypeParameter[] ret = new Signature.FormalTypeParameter[typeParameters.size()];
+ typeParameters.toArray(ret);
+ return ret;
+ }
+
}
\ No newline at end of file
return resolvedTypeX.isNested();
}
+ public ResolvedType getOuterClass() {
+ return resolvedTypeX.getOuterClass();
+ }
+
public String getRetentionPolicy() {
return resolvedTypeX.getRetentionPolicy();
}
}
public boolean isAnonymous() {
- return delegate.isAnonymous();
+ return delegate.isAnonymous();
}
public boolean isNested() {
- return delegate.isNested();
+ return delegate.isNested();
+ }
+
+ public ResolvedType getOuterClass() {
+ return delegate.getOuterClass();
}
public String getRetentionPolicy() {
public String getSourcefilename();
public String getDeclaredGenericSignature();
+ public ResolvedType getOuterClass();
}
\ No newline at end of file
import org.aspectj.apache.bcel.classfile.GenericSignatureParser;
import org.aspectj.apache.bcel.classfile.Signature;
+import org.aspectj.org.objectweb.asm.Attribute;
+import org.aspectj.org.objectweb.asm.ClassReader;
+import org.aspectj.org.objectweb.asm.Opcodes;
import org.aspectj.weaver.AbstractReferenceTypeDelegate;
import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.AnnotationAJ;
import org.aspectj.weaver.AnnotationX;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.ReferenceType;
-import org.aspectj.weaver.ReferenceTypeDelegate;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedMemberImpl;
import org.aspectj.weaver.ResolvedPointcutDefinition;
import org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter;
import org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXConverter.GenericSignatureFormatException;
import org.aspectj.weaver.patterns.PerClause;
-import org.aspectj.org.objectweb.asm.Attribute;
-import org.aspectj.org.objectweb.asm.ClassReader;
-import org.aspectj.org.objectweb.asm.Opcodes;
/**
* A lightweight fast delegate that is an alternative to a BCEL delegate.
public String getDeclaredGenericSignature() {
return declaredSignature;
}
+
public Collection getTypeMungers() {
if ((bitflag&DISCOVERED_TYPEMUNGERS)==0) {
}
- private ReferenceType getOuterClass() {
+ public ResolvedType getOuterClass() {
if (!isNested()) throw new IllegalStateException("Can't get the outer class of a non-nested type");
int lastDollar = getResolvedTypeX().getName().lastIndexOf('$');
String superClassName = getResolvedTypeX().getName().substring(0,lastDollar);
return (ReferenceType) outer.resolve(getResolvedTypeX().getWorld());
}
- private Signature.FormalTypeParameter[] getFormalTypeParametersFromOuterClass() {
- List typeParameters = new ArrayList();
- ReferenceType outer = getOuterClass();
- ReferenceTypeDelegate outerDelegate = outer.getDelegate();
- if (!(outerDelegate instanceof AsmDelegate)) {
- throw new IllegalStateException("How come we're in AsmObjectType resolving an inner type of something that is NOT a AsmObjectType??");
- }
- AsmDelegate outerObjectType = (AsmDelegate) outerDelegate;
- if (outerObjectType.isNested()) {
- Signature.FormalTypeParameter[] parentParams = outerObjectType.getFormalTypeParametersFromOuterClass();
- for (int i = 0; i < parentParams.length; i++) {
- typeParameters.add(parentParams[i]);
- }
- }
- GenericSignatureParser parser = new GenericSignatureParser();
- String sig = outerObjectType.getDeclaredGenericSignature();
- if (sig!=null) {
- Signature.ClassSignature outerSig = parser.parseAsClassSignature(sig);
- if (outerSig != null) {
- for (int i = 0; i < outerSig.formalTypeParameters .length; i++) {
- typeParameters.add(outerSig.formalTypeParameters[i]);
- }
- }
- }
-
- Signature.FormalTypeParameter[] ret = new Signature.FormalTypeParameter[typeParameters.size()];
- typeParameters.toArray(ret);
- return ret;
- }
- // ---
+
public boolean isInterface() {
return (classModifiers & Opcodes.ACC_INTERFACE)!=0;
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.apache.bcel.classfile.Signature;
-import org.aspectj.apache.bcel.classfile.Signature.ClassSignature;
import org.aspectj.apache.bcel.classfile.annotation.Annotation;
import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValue;
import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair;
import org.aspectj.weaver.AnnotationX;
import org.aspectj.weaver.BCException;
import org.aspectj.weaver.ReferenceType;
-import org.aspectj.weaver.ReferenceTypeDelegate;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedPointcutDefinition;
import org.aspectj.weaver.ResolvedType;
private List declares = Collections.EMPTY_LIST;
private Signature.FormalTypeParameter[] formalsForResolution = null;
- private ClassSignature cachedGenericClassTypeSignature;
private String declaredSignature = null;
modifiers = javaClass.getAccessFlags();
superclassName = javaClass.getSuperclassName();
className = javaClass.getClassName();
- cachedGenericClassTypeSignature = javaClass.getGenericClassTypeSignature();
+ cachedGenericClassTypeSignature = null;
}
if (!isGeneric()) return TypeVariable.NONE;
if (typeVars == null) {
- Signature.ClassSignature classSig = cachedGenericClassTypeSignature;//javaClass.getGenericClassTypeSignature();
+ Signature.ClassSignature classSig = getGenericClassTypeSignature();//cachedGenericClassTypeSignature;//javaClass.getGenericClassTypeSignature();
typeVars = new TypeVariable[classSig.formalTypeParameters.length];
for (int i = 0; i < typeVars.length; i++) {
Signature.FormalTypeParameter ftp = classSig.formalTypeParameters[i];
return declaredSignature;
}
- Signature.ClassSignature getGenericClassTypeSignature() {
- return cachedGenericClassTypeSignature;
- }
-
private void ensureGenericSignatureUnpacked() {
if ((bitflag&UNPACKED_GENERIC_SIGNATURE)!=0) return;
Signature.ClassSignature cSig = getGenericClassTypeSignature();
if (cSig != null) {
formalsForResolution = cSig.formalTypeParameters;
- if (isNestedClass()) {
+ if (isNested()) {
// we have to find any type variables from the outer type before proceeding with resolution.
Signature.FormalTypeParameter[] extraFormals = getFormalTypeParametersFromOuterClass();
if (extraFormals.length > 0) {
}
}
- private boolean isNestedClass() {
- return className.indexOf('$') != -1;
- }
- private ReferenceType getOuterClass() {
- if (!isNestedClass()) throw new IllegalStateException("Can't get the outer class of a non-nested type");
+ public ResolvedType getOuterClass() {
+ if (!isNested()) throw new IllegalStateException("Can't get the outer class of a non-nested type");
int lastDollar = className.lastIndexOf('$');
String superClassName = className.substring(0,lastDollar);
UnresolvedType outer = UnresolvedType.forName(superClassName);
return (ReferenceType) outer.resolve(getResolvedTypeX().getWorld());
}
- private Signature.FormalTypeParameter[] getFormalTypeParametersFromOuterClass() {
- List typeParameters = new ArrayList();
- ReferenceType outer = getOuterClass();
- ReferenceTypeDelegate outerDelegate = outer.getDelegate();
- if (!(outerDelegate instanceof BcelObjectType)) {
- throw new IllegalStateException("How come we're in BcelObjectType resolving an inner type of something that is NOT a BcelObjectType??");
- }
- BcelObjectType outerObjectType = (BcelObjectType) outerDelegate;
- if (outerObjectType.isNestedClass()) {
- Signature.FormalTypeParameter[] parentParams = outerObjectType.getFormalTypeParametersFromOuterClass();
- for (int i = 0; i < parentParams.length; i++) {
- typeParameters.add(parentParams[i]);
- }
- }
- Signature.ClassSignature outerSig = outerObjectType.getGenericClassTypeSignature();
- if (outerSig != null) {
- for (int i = 0; i < outerSig.formalTypeParameters .length; i++) {
- typeParameters.add(outerSig.formalTypeParameters[i]);
- }
- }
-
- Signature.FormalTypeParameter[] ret = new Signature.FormalTypeParameter[typeParameters.size()];
- typeParameters.toArray(ret);
- return ret;
- }
private void ensureGenericInfoProcessed() {
if ((bitflag & DISCOVERED_DECLARED_SIGNATURE)!=0) return;
// boolean member = this.myClass.isMemberClass();
// return member;
}
+
+ public ResolvedType getOuterClass() {
+ // FIXME getEnclosingClass() is Java5 ... dammit
+// return ReflectionBasedReferenceTypeDelegateFactory.resolveTypeInWorld(myClass.getEnclosingClass(),world);
+ return null;
+ }
/* (non-Javadoc)
* @see org.aspectj.weaver.ReferenceTypeDelegate#isExposedToWeaver()