if (accumulatedAnnotations.size() == 0) { | if (accumulatedAnnotations.size() == 0) { | ||||
annotations = AnnotationGen.NO_ANNOTATIONS; | annotations = AnnotationGen.NO_ANNOTATIONS; | ||||
} else { | } else { | ||||
annotations = accumulatedAnnotations.toArray(new AnnotationGen[] {}); | |||||
annotations = accumulatedAnnotations.toArray(AnnotationGen.NO_ANNOTATIONS); | |||||
} | } | ||||
} | } | ||||
return annotations; | return annotations; |
public class JavaClass extends Modifiers implements Cloneable, Node { | public class JavaClass extends Modifiers implements Cloneable, Node { | ||||
private static final String[] NoInterfaceNames = new String[0]; | private static final String[] NoInterfaceNames = new String[0]; | ||||
private static final Field[] NoFields = new Field[0]; | |||||
private static final Method[] NoMethod = new Method[0]; | |||||
private static final int[] NoInterfaceIndices = new int[0]; | private static final int[] NoInterfaceIndices = new int[0]; | ||||
private static final Attribute[] NoAttributes = new Attribute[0]; | |||||
private String fileName; | private String fileName; | ||||
private String packageName; | private String packageName; | ||||
this.modifiers = access_flags; | this.modifiers = access_flags; | ||||
this.cpool = cpool; | this.cpool = cpool; | ||||
this.interfaces = interfaces; | this.interfaces = interfaces; | ||||
this.fields = (fields == null ? NoFields : fields); | |||||
this.methods = (methods == null ? NoMethod : methods); | |||||
this.attributes = (attributes == null ? NoAttributes : attributes); | |||||
this.fields = (fields == null ? Field.NoFields : fields); | |||||
this.methods = (methods == null ? Method.NoMethods : methods); | |||||
this.attributes = (attributes == null ? Attribute.NoAttributes : attributes); | |||||
annotationsOutOfDate = true; | annotationsOutOfDate = true; | ||||
// Get source file name if available | // Get source file name if available | ||||
accumulatedAnnotations.addAll(runtimeAnnotations.getAnnotations()); | accumulatedAnnotations.addAll(runtimeAnnotations.getAnnotations()); | ||||
} | } | ||||
} | } | ||||
annotations = accumulatedAnnotations.toArray(new AnnotationGen[] {}); | |||||
annotations = accumulatedAnnotations.toArray(AnnotationGen.NO_ANNOTATIONS); | |||||
annotationsOutOfDate = false; | annotationsOutOfDate = false; | ||||
} | } | ||||
return annotations; | return annotations; |
AnnotationGen[] invisibleOnes = null; | AnnotationGen[] invisibleOnes = null; | ||||
for (int i = 0; i < parameterCount; i++) { | for (int i = 0; i < parameterCount; i++) { | ||||
int count = 0; | int count = 0; | ||||
visibleOnes = new AnnotationGen[0]; | |||||
invisibleOnes = new AnnotationGen[0]; | |||||
visibleOnes = AnnotationGen.NO_ANNOTATIONS; | |||||
invisibleOnes = AnnotationGen.NO_ANNOTATIONS; | |||||
if (parameterAnnotationsVis != null) { | if (parameterAnnotationsVis != null) { | ||||
visibleOnes = parameterAnnotationsVis.getAnnotationsOnParameter(i); | visibleOnes = parameterAnnotationsVis.getAnnotationsOnParameter(i); | ||||
count += visibleOnes.length; | count += visibleOnes.length; |
newAttributes.add(new RuntimeInvisParamAnnos(riaIndex, riaData.length, riaData, cp)); | newAttributes.add(new RuntimeInvisParamAnnos(riaIndex, riaData.length, riaData, cp)); | ||||
} | } | ||||
return newAttributes.toArray(new Attribute[] {}); | |||||
return newAttributes.toArray(Attribute.NoAttributes); | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
System.err.println("IOException whilst processing parameter annotations"); | System.err.println("IOException whilst processing parameter annotations"); | ||||
e.printStackTrace(); | e.printStackTrace(); |
ConstantPool cp = this.cpool.getFinalConstantPool(); | ConstantPool cp = this.cpool.getFinalConstantPool(); | ||||
return new JavaClass(classnameIndex, superclassnameIndex, filename, major, minor, modifiers, cp, interfaces, fields, | return new JavaClass(classnameIndex, superclassnameIndex, filename, major, minor, modifiers, cp, interfaces, fields, | ||||
methods, attributes.toArray(new Attribute[0]));// OPTIMIZE avoid toArray()? | |||||
methods, attributes.toArray(Attribute.NoAttributes));// OPTIMIZE avoid toArray()? | |||||
} | } | ||||
public void addInterface(String name) { | public void addInterface(String name) { |
*/ | */ | ||||
public static IMessage[] getMessagesExcept(IMessageHolder holder, final IMessage.Kind kind, final boolean orGreater) { | public static IMessage[] getMessagesExcept(IMessageHolder holder, final IMessage.Kind kind, final boolean orGreater) { | ||||
if ((null == holder) || (null == kind)) { | if ((null == holder) || (null == kind)) { | ||||
return new IMessage[0]; | |||||
return IMessage.RA_IMessage; | |||||
} | } | ||||
IMessageHandler selector = new IMessageHandler() { | IMessageHandler selector = new IMessageHandler() { |
*******************************************************************************/ | *******************************************************************************/ | ||||
package org.aspectj.weaver.loadtime; | package org.aspectj.weaver.loadtime; | ||||
import static org.aspectj.apache.bcel.generic.Type.NO_ARGS; | |||||
import java.lang.reflect.Modifier; | import java.lang.reflect.Modifier; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
public class ConcreteAspectCodeGen { | public class ConcreteAspectCodeGen { | ||||
private final static String[] EMPTY_STRINGS = new String[0]; | private final static String[] EMPTY_STRINGS = new String[0]; | ||||
private final static Type[] EMPTY_TYPES = new Type[0]; | |||||
/** | /** | ||||
* Concrete aspect definition we build for | * Concrete aspect definition we build for | ||||
} | } | ||||
// default constructor | // default constructor | ||||
LazyMethodGen init = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, "<init>", EMPTY_TYPES, EMPTY_STRINGS, cg); | |||||
LazyMethodGen init = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, "<init>", NO_ARGS, EMPTY_STRINGS, cg); | |||||
InstructionList cbody = init.getBody(); | InstructionList cbody = init.getBody(); | ||||
cbody.append(InstructionConstants.ALOAD_0); | cbody.append(InstructionConstants.ALOAD_0); | ||||
cbody.append(cg.getFactory().createInvoke(parentName, "<init>", Type.VOID, EMPTY_TYPES, Constants.INVOKESPECIAL)); | |||||
cbody.append(cg.getFactory().createInvoke(parentName, "<init>", Type.VOID, NO_ARGS, Constants.INVOKESPECIAL)); | |||||
cbody.append(InstructionConstants.RETURN); | cbody.append(InstructionConstants.RETURN); | ||||
cg.addMethodGen(init); | cg.addMethodGen(init); | ||||
for (Definition.Pointcut abstractPc : concreteAspect.pointcuts) { | for (Definition.Pointcut abstractPc : concreteAspect.pointcuts) { | ||||
// TODO AV - respect visibility instead of opening up as public? | // TODO AV - respect visibility instead of opening up as public? | ||||
LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, abstractPc.name, EMPTY_TYPES, EMPTY_STRINGS, cg); | |||||
LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, abstractPc.name, NO_ARGS, EMPTY_STRINGS, cg); | |||||
SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), abstractPc.expression); | SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), abstractPc.expression); | ||||
List<NameValuePair> elems = new ArrayList<>(); | List<NameValuePair> elems = new ArrayList<>(); | ||||
elems.add(new NameValuePair("value", svg, cg.getConstantPool())); | elems.add(new NameValuePair("value", svg, cg.getConstantPool())); | ||||
String nameComponent = da.declareAnnotationKind.name().toLowerCase(); | String nameComponent = da.declareAnnotationKind.name().toLowerCase(); | ||||
String declareName = new StringBuilder("ajc$declare_at_").append(nameComponent).append("_").append(decCounter).toString(); | String declareName = new StringBuilder("ajc$declare_at_").append(nameComponent).append("_").append(decCounter).toString(); | ||||
LazyMethodGen declareMethod = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, declareName, Type.NO_ARGS, EMPTY_STRINGS, cg); | |||||
LazyMethodGen declareMethod = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, declareName, NO_ARGS, EMPTY_STRINGS, cg); | |||||
InstructionList declareMethodBody = declareMethod.getBody(); | InstructionList declareMethodBody = declareMethod.getBody(); | ||||
declareMethodBody.append(InstructionFactory.RETURN); | declareMethodBody.append(InstructionFactory.RETURN); | ||||
declareMethod.addAnnotation(constructedAnnotation); | declareMethod.addAnnotation(constructedAnnotation); | ||||
} | } | ||||
// Time to construct the method itself: | // Time to construct the method itself: | ||||
LazyMethodGen advice = new LazyMethodGen(Modifier.PUBLIC, returnType, adviceName, paramTypes.toArray(new Type[0]), EMPTY_STRINGS, cg); | |||||
LazyMethodGen advice = new LazyMethodGen(Modifier.PUBLIC, returnType, adviceName, paramTypes.toArray(NO_ARGS), EMPTY_STRINGS, cg); | |||||
InstructionList adviceBody = advice.getBody(); | InstructionList adviceBody = advice.getBody(); | ||||
// XXX set these correctly | // XXX set these correctly | ||||
formalsUnchangedToProceed = new boolean[baseArgumentCount]; | formalsUnchangedToProceed = new boolean[baseArgumentCount]; | ||||
proceedCallSignatures = new ResolvedMember[0]; | |||||
proceedCallSignatures = ResolvedMember.NONE; | |||||
proceedInInners = false; | proceedInInners = false; | ||||
declaredExceptions = new UnresolvedType[0]; | |||||
declaredExceptions = UnresolvedType.NONE; | |||||
for (Proceed call : proceedCalls) { | for (Proceed call : proceedCalls) { | ||||
if (call.inInner) { | if (call.inInner) { |
} | } | ||||
private PerClause resolvePerClause() { | private PerClause resolvePerClause() { | ||||
EclipseScope iscope = new EclipseScope(new FormalBinding[0], scope); | |||||
EclipseScope iscope = new EclipseScope(FormalBinding.NONE, scope); | |||||
perClause.resolve(iscope); | perClause.resolve(iscope); | ||||
return perClause; | return perClause; | ||||
} | } |
return null; | return null; | ||||
} | } | ||||
EclipseScope scope = new EclipseScope(new FormalBinding[0], classScope); | |||||
EclipseScope scope = new EclipseScope(FormalBinding.NONE, classScope); | |||||
declareDecl.resolve(scope); | declareDecl.resolve(scope); | ||||
return declareDecl; | return declareDecl; |
if (perClause != null && !perClause.equals("")) { | if (perClause != null && !perClause.equals("")) { | ||||
ISourceContext context = new EclipseSourceContext(unit.compilationResult, pcLoc[0]); | ISourceContext context = new EclipseSourceContext(unit.compilationResult, pcLoc[0]); | ||||
Pointcut pc = new PatternParser(perClause, context).maybeParsePerClause(); | Pointcut pc = new PatternParser(perClause, context).maybeParsePerClause(); | ||||
FormalBinding[] bindings = new FormalBinding[0]; | |||||
FormalBinding[] bindings = FormalBinding.NONE; | |||||
if (pc != null) | if (pc != null) | ||||
pc.resolve(new EclipseScope(bindings, typeDecl.scope)); | pc.resolve(new EclipseScope(bindings, typeDecl.scope)); | ||||
} | } | ||||
private FormalBinding[] buildFormalAdviceBindingsFrom(MethodDeclaration mDecl) { | private FormalBinding[] buildFormalAdviceBindingsFrom(MethodDeclaration mDecl) { | ||||
if (mDecl.arguments == null) | if (mDecl.arguments == null) | ||||
return new FormalBinding[0]; | |||||
return FormalBinding.NONE; | |||||
if (mDecl.binding == null) | if (mDecl.binding == null) | ||||
return new FormalBinding[0]; | |||||
return FormalBinding.NONE; | |||||
EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(mDecl.scope); | EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(mDecl.scope); | ||||
String extraArgName = maybeGetExtraArgName(); | String extraArgName = maybeGetExtraArgName(); | ||||
if (extraArgName == null) | if (extraArgName == null) |
// act of resolution here may cause recursion problems since the parameters may | // act of resolution here may cause recursion problems since the parameters may | ||||
// be type variables that we haven't fixed up yet. | // be type variables that we haven't fixed up yet. | ||||
if (arguments == null) { | if (arguments == null) { | ||||
arguments = new UnresolvedType[0]; | |||||
arguments = UnresolvedType.NONE; | |||||
// for pr384398 | // for pr384398 | ||||
if (!hasAnyArguments(ptb)) { | if (!hasAnyArguments(ptb)) { | ||||
return UnresolvedType.forRawTypeName(getName(binding)); | return UnresolvedType.forRawTypeName(getName(binding)); |
declaredFields.add(factory.makeResolvedMember(f)); | declaredFields.add(factory.makeResolvedMember(f)); | ||||
} | } | ||||
this.declaredPointcuts = declaredPointcuts.toArray(new ResolvedPointcutDefinition[0]); | |||||
this.declaredMethods = declaredMethods.toArray(new ResolvedMember[0]); | |||||
this.declaredFields = declaredFields.toArray(new ResolvedMember[0]); | |||||
this.declaredPointcuts = declaredPointcuts.toArray(ResolvedPointcutDefinition.NO_POINTCUTS); | |||||
this.declaredMethods = declaredMethods.toArray(ResolvedMember.NONE); | |||||
this.declaredFields = declaredFields.toArray(ResolvedMember.NONE); | |||||
} | } | ||||
private final static char[] valuesCharArray = "values".toCharArray(); | private final static char[] valuesCharArray = "values".toCharArray(); | ||||
private FormalBinding[] buildFormalAdviceBindingsFrom(AbstractMethodDeclaration mDecl) { | private FormalBinding[] buildFormalAdviceBindingsFrom(AbstractMethodDeclaration mDecl) { | ||||
if (mDecl.arguments == null) { | if (mDecl.arguments == null) { | ||||
return new FormalBinding[0]; | |||||
return FormalBinding.NONE; | |||||
} | } | ||||
if (mDecl.binding == null) { | if (mDecl.binding == null) { | ||||
return new FormalBinding[0]; | |||||
return FormalBinding.NONE; | |||||
} | } | ||||
EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(mDecl.scope); | EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(mDecl.scope); | ||||
String extraArgName = "";// maybeGetExtraArgName(); | String extraArgName = "";// maybeGetExtraArgName(); | ||||
@Override | @Override | ||||
public TypeVariable[] getTypeVariables() { | public TypeVariable[] getTypeVariables() { | ||||
if (declaration.typeParameters == null) { | if (declaration.typeParameters == null) { | ||||
return new TypeVariable[0]; | |||||
return TypeVariable.NONE; | |||||
} | } | ||||
TypeVariable[] typeVariables = new TypeVariable[declaration.typeParameters.length]; | TypeVariable[] typeVariables = new TypeVariable[declaration.typeParameters.length]; | ||||
for (int i = 0; i < typeVariables.length; i++) { | for (int i = 0; i < typeVariables.length; i++) { |
if (signature != null) { | if (signature != null) { | ||||
bindingParameterTypes = signature.getParameterTypes(); | bindingParameterTypes = signature.getParameterTypes(); | ||||
} else { | } else { | ||||
bindingParameterTypes = new UnresolvedType[0]; | |||||
bindingParameterTypes = UnresolvedType.NONE; | |||||
} | } | ||||
} | } | ||||
// public static a.X ajc$createAspectInstance(java.lang.String) | // public static a.X ajc$createAspectInstance(java.lang.String) | ||||
ResolvedMemberImpl rm = new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, declaringType, // return value | ResolvedMemberImpl rm = new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, declaringType, // return value | ||||
NameMangler.PERTYPEWITHIN_CREATEASPECTINSTANCE_METHOD, | NameMangler.PERTYPEWITHIN_CREATEASPECTINSTANCE_METHOD, | ||||
new UnresolvedType[] { UnresolvedType.forSignature("Ljava/lang/String;") }, new UnresolvedType[] {}); | |||||
new UnresolvedType[] { UnresolvedType.forSignature("Ljava/lang/String;") }, UnresolvedType.NONE); | |||||
return rm; | return rm; | ||||
} | } | ||||
l.add(UnresolvedType.forSignature(sig.substring(start, i))); | l.add(UnresolvedType.forSignature(sig.substring(start, i))); | ||||
} | } | ||||
} | } | ||||
UnresolvedType[] paramTypes = l.toArray(new UnresolvedType[0]); | |||||
UnresolvedType[] paramTypes = l.toArray(UnresolvedType.NONE); | |||||
UnresolvedType returnType = UnresolvedType.forSignature(sig.substring(i + 1, sig.length())); | UnresolvedType returnType = UnresolvedType.forSignature(sig.substring(i + 1, sig.length())); | ||||
return new Object[] { returnType, paramTypes }; | return new Object[] { returnType, paramTypes }; | ||||
} else { | } else { |
*/ | */ | ||||
public class MissingResolvedTypeWithKnownSignature extends ResolvedType { | public class MissingResolvedTypeWithKnownSignature extends ResolvedType { | ||||
private static ResolvedMember[] NO_MEMBERS = new ResolvedMember[0]; | |||||
private static ResolvedType[] NO_TYPES = new ResolvedType[0]; | |||||
private boolean issuedCantFindTypeError = false; | private boolean issuedCantFindTypeError = false; | ||||
private boolean issuedJoinPointWarning = false; | private boolean issuedJoinPointWarning = false; | ||||
private boolean issuedMissingInterfaceWarning = false; | private boolean issuedMissingInterfaceWarning = false; | ||||
@Override | @Override | ||||
public ResolvedMember[] getDeclaredFields() { | public ResolvedMember[] getDeclaredFields() { | ||||
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_FIELDS); | raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_FIELDS); | ||||
return NO_MEMBERS; | |||||
return ResolvedMember.NONE; | |||||
} | } | ||||
/* | /* | ||||
@Override | @Override | ||||
public ResolvedMember[] getDeclaredMethods() { | public ResolvedMember[] getDeclaredMethods() { | ||||
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_METHODS); | raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_METHODS); | ||||
return NO_MEMBERS; | |||||
return ResolvedMember.NONE; | |||||
} | } | ||||
@Override | @Override | ||||
@Override | @Override | ||||
public ResolvedType[] getDeclaredInterfaces() { | public ResolvedType[] getDeclaredInterfaces() { | ||||
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_INTERFACES); | raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_INTERFACES); | ||||
return NO_TYPES; | |||||
return ResolvedType.EMPTY_RESOLVED_TYPE_ARRAY; | |||||
} | } | ||||
@Override | @Override | ||||
public ResolvedMember[] getDeclaredPointcuts() { | public ResolvedMember[] getDeclaredPointcuts() { | ||||
raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_POINTCUTS); | raiseCantFindType(WeaverMessages.CANT_FIND_TYPE_POINTCUTS); | ||||
return NO_MEMBERS; | |||||
return ResolvedMember.NONE; | |||||
} | } | ||||
@Override | @Override |
l.add(m); | l.add(m); | ||||
} | } | ||||
} | } | ||||
return l.toArray(new ResolvedMember[0]); | |||||
return l.toArray(ResolvedMember.NONE); | |||||
} | } | ||||
public abstract ISourceContext getSourceContext(); | public abstract ISourceContext getSourceContext(); |
private AnnotationTypePattern[] typePatterns; | private AnnotationTypePattern[] typePatterns; | ||||
int ellipsisCount = 0; | int ellipsisCount = 0; | ||||
public static final AnnotationPatternList EMPTY = new AnnotationPatternList(new AnnotationTypePattern[] {}); | |||||
public static final AnnotationPatternList EMPTY = new AnnotationPatternList(AnnotationTypePattern.NONE); | |||||
public static final AnnotationPatternList ANY = new AnnotationPatternList( | public static final AnnotationPatternList ANY = new AnnotationPatternList( | ||||
new AnnotationTypePattern[] { AnnotationTypePattern.ELLIPSIS }); | new AnnotationTypePattern[] { AnnotationTypePattern.ELLIPSIS }); | ||||
public AnnotationPatternList() { | public AnnotationPatternList() { | ||||
typePatterns = new AnnotationTypePattern[0]; | |||||
typePatterns = AnnotationTypePattern.NONE; | |||||
ellipsisCount = 0; | ellipsisCount = 0; | ||||
} | } | ||||
} | } | ||||
public AnnotationPatternList(List<AnnotationTypePattern> l) { | public AnnotationPatternList(List<AnnotationTypePattern> l) { | ||||
this((AnnotationTypePattern[]) l.toArray(new AnnotationTypePattern[0])); | |||||
this((AnnotationTypePattern[]) l.toArray(AnnotationTypePattern.NONE)); | |||||
} | } | ||||
protected AnnotationTypePattern[] getAnnotationPatterns() { | protected AnnotationTypePattern[] getAnnotationPatterns() { |
} | } | ||||
} | } | ||||
ret = Test.makeAnd(ret, Test.makeCall(testMethod, (Expr[]) args.toArray(new Expr[0]))); | |||||
ret = Test.makeAnd(ret, Test.makeCall(testMethod, (Expr[]) args.toArray(Expr.NONE))); | |||||
// Remember... | // Remember... | ||||
ifLastMatchedShadowId = shadow.shadowId; | ifLastMatchedShadowId = shadow.shadowId; |
*/ | */ | ||||
public ResolvedType[] getAnnotationTypes() { | public ResolvedType[] getAnnotationTypes() { | ||||
// no annotations in Java 1.4 | // no annotations in Java 1.4 | ||||
return new ResolvedType[0]; | |||||
return ResolvedType.EMPTY_RESOLVED_TYPE_ARRAY; | |||||
} | } | ||||
/* | /* | ||||
* @see org.aspectj.weaver.ReferenceTypeDelegate#getDeclaredPointcuts() | * @see org.aspectj.weaver.ReferenceTypeDelegate#getDeclaredPointcuts() | ||||
*/ | */ | ||||
public ResolvedMember[] getDeclaredPointcuts() { | public ResolvedMember[] getDeclaredPointcuts() { | ||||
return new ResolvedMember[0]; | |||||
return ResolvedMember.NONE; | |||||
} | } | ||||
/* | /* | ||||
*/ | */ | ||||
public TypeVariable[] getTypeVariables() { | public TypeVariable[] getTypeVariables() { | ||||
// no type variables in Java 1.4 | // no type variables in Java 1.4 | ||||
return new TypeVariable[0]; | |||||
return TypeVariable.NONE; | |||||
} | } | ||||
/* | /* |
public static ResolvedMember createStaticInitMember(Class forType, World inWorld) { | public static ResolvedMember createStaticInitMember(Class forType, World inWorld) { | ||||
return new ResolvedMemberImpl(org.aspectj.weaver.Member.STATIC_INITIALIZATION, toResolvedType(forType, | return new ResolvedMemberImpl(org.aspectj.weaver.Member.STATIC_INITIALIZATION, toResolvedType(forType, | ||||
(IReflectionWorld) inWorld), Modifier.STATIC, UnresolvedType.VOID, "<clinit>", new UnresolvedType[0], | |||||
new UnresolvedType[0]); | |||||
(IReflectionWorld) inWorld), Modifier.STATIC, UnresolvedType.VOID, "<clinit>", UnresolvedType.NONE, | |||||
UnresolvedType.NONE); | |||||
} | } | ||||
public static ResolvedMember createResolvedConstructor(Constructor aConstructor, World inWorld) { | public static ResolvedMember createResolvedConstructor(Constructor aConstructor, World inWorld) { | ||||
public static ResolvedMember createResolvedField(Field aField, World inWorld) { | public static ResolvedMember createResolvedField(Field aField, World inWorld) { | ||||
ReflectionBasedResolvedMemberImpl ret = new ReflectionBasedResolvedMemberImpl(org.aspectj.weaver.Member.FIELD, | ReflectionBasedResolvedMemberImpl ret = new ReflectionBasedResolvedMemberImpl(org.aspectj.weaver.Member.FIELD, | ||||
toResolvedType(aField.getDeclaringClass(), (IReflectionWorld) inWorld), aField.getModifiers(), toResolvedType( | toResolvedType(aField.getDeclaringClass(), (IReflectionWorld) inWorld), aField.getModifiers(), toResolvedType( | ||||
aField.getType(), (IReflectionWorld) inWorld), aField.getName(), new UnresolvedType[0], aField); | |||||
aField.getType(), (IReflectionWorld) inWorld), aField.getName(), UnresolvedType.NONE, aField); | |||||
if (inWorld instanceof IReflectionWorld) { | if (inWorld instanceof IReflectionWorld) { | ||||
ret.setAnnotationFinder(((IReflectionWorld) inWorld).getAnnotationFinder()); | ret.setAnnotationFinder(((IReflectionWorld) inWorld).getAnnotationFinder()); | ||||
} | } |
Kind kind = Shadow.StaticInitialization; | Kind kind = Shadow.StaticInitialization; | ||||
if (clinit == -1) { | if (clinit == -1) { | ||||
Member clinitMember = new ResolvedMemberImpl(org.aspectj.weaver.Member.STATIC_INITIALIZATION, forType, Modifier.STATIC, | Member clinitMember = new ResolvedMemberImpl(org.aspectj.weaver.Member.STATIC_INITIALIZATION, forType, Modifier.STATIC, | ||||
UnresolvedType.VOID, "<clinit>", new UnresolvedType[0], new UnresolvedType[0]); | |||||
UnresolvedType.VOID, "<clinit>", UnresolvedType.NONE, UnresolvedType.NONE); | |||||
return new StandardShadow(inWorld, kind, clinitMember, null, forType, null, withContext); | return new StandardShadow(inWorld, kind, clinitMember, null, forType, null, withContext); | ||||
} else { | } else { | ||||
return new StandardShadow(inWorld, kind, members[clinit], null, forType, null, withContext); | return new StandardShadow(inWorld, kind, members[clinit], null, forType, null, withContext); |
} | } | ||||
public static class MethodTypeSignature { | public static class MethodTypeSignature { | ||||
public FormalTypeParameter[] formalTypeParameters = new FormalTypeParameter[0]; | |||||
public FormalTypeParameter[] formalTypeParameters = FormalTypeParameter.NONE; | |||||
public TypeSignature[] parameters = new TypeSignature[0]; | public TypeSignature[] parameters = new TypeSignature[0]; | ||||
public TypeSignature returnType; | public TypeSignature returnType; | ||||
public FieldTypeSignature[] throwsSignatures = new FieldTypeSignature[0]; | public FieldTypeSignature[] throwsSignatures = new FieldTypeSignature[0]; |
this.inputString = sig; | this.inputString = sig; | ||||
tokenStream = tokenize(sig); | tokenStream = tokenize(sig); | ||||
tokenIndex = 0; | tokenIndex = 0; | ||||
FormalTypeParameter[] formals = new FormalTypeParameter[0]; | |||||
FormalTypeParameter[] formals = FormalTypeParameter.NONE; | |||||
TypeSignature returnType = null; | TypeSignature returnType = null; | ||||
// FormalTypeParameters-opt | // FormalTypeParameters-opt | ||||
if (maybeEat("<")) { | if (maybeEat("<")) { |
// struct.ajAttributes.add(new AjAttribute.WeaverVersionInfo()); | // struct.ajAttributes.add(new AjAttribute.WeaverVersionInfo()); | ||||
AjAttribute.Aspect aspectAttribute = new AjAttribute.Aspect(perClause); | AjAttribute.Aspect aspectAttribute = new AjAttribute.Aspect(perClause); | ||||
struct.ajAttributes.add(aspectAttribute); | struct.ajAttributes.add(aspectAttribute); | ||||
FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0]; | |||||
FormalBinding[] bindings = FormalBinding.NONE; | |||||
final IScope binding; | final IScope binding; | ||||
binding = new BindingScope(struct.enclosingType, struct.context, bindings); | binding = new BindingScope(struct.enclosingType, struct.context, bindings); | ||||
} | } | ||||
if (fieldType.isInterface()) { | if (fieldType.isInterface()) { | ||||
TypePattern parent = parseTypePattern(fieldType.getName(), struct); | TypePattern parent = parseTypePattern(fieldType.getName(), struct); | ||||
FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0]; | |||||
FormalBinding[] bindings = FormalBinding.NONE; | |||||
IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings); | IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings); | ||||
// first add the declare implements like | // first add the declare implements like | ||||
List<TypePattern> parents = new ArrayList<>(1); | List<TypePattern> parents = new ArrayList<>(1); | ||||
} | } | ||||
// Create the declare parents that will add the interfaces to matching targets | // Create the declare parents that will add the interfaces to matching targets | ||||
FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0]; | |||||
FormalBinding[] bindings = FormalBinding.NONE; | |||||
IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings); | IScope binding = new BindingScope(struct.enclosingType, struct.context, bindings); | ||||
// how do we mark this as a decp due to decmixin? | // how do we mark this as a decp due to decmixin? | ||||
DeclareParents dp = new DeclareParentsMixin(targetTypePattern, newParents); | DeclareParents dp = new DeclareParentsMixin(targetTypePattern, newParents); | ||||
// TODO check for overlapping interfaces. Eg. A implements I, I extends J - if they specify interfaces={I,J} we dont | // TODO check for overlapping interfaces. Eg. A implements I, I extends J - if they specify interfaces={I,J} we dont | ||||
// want to do any methods twice | // want to do any methods twice | ||||
ResolvedMember[] methods = typeForDelegation.getMethodsWithoutIterator(true, false, false).toArray( | ResolvedMember[] methods = typeForDelegation.getMethodsWithoutIterator(true, false, false).toArray( | ||||
new ResolvedMember[0]); | |||||
ResolvedMember.NONE); | |||||
for (ResolvedMember resolvedMember : methods) { | for (ResolvedMember resolvedMember : methods) { | ||||
ResolvedMember method = resolvedMember; | ResolvedMember method = resolvedMember; | ||||
if (method.isAbstract()) { | if (method.isAbstract()) { | ||||
if (argumentNames != null) { | if (argumentNames != null) { | ||||
struct.unparsedArgumentNames = argumentNames; | struct.unparsedArgumentNames = argumentNames; | ||||
} | } | ||||
FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0]; | |||||
FormalBinding[] bindings = FormalBinding.NONE; | |||||
try { | try { | ||||
bindings = extractBindings(struct); | bindings = extractBindings(struct); | ||||
} catch (UnreadableDebugInfoException unreadableDebugInfoException) { | } catch (UnreadableDebugInfoException unreadableDebugInfoException) { | ||||
NameValuePair afterAdvice = getAnnotationElement(after, VALUE); | NameValuePair afterAdvice = getAnnotationElement(after, VALUE); | ||||
if (afterAdvice != null) { | if (afterAdvice != null) { | ||||
// this/target/args binding | // this/target/args binding | ||||
FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0]; | |||||
FormalBinding[] bindings = FormalBinding.NONE; | |||||
String argumentNames = getArgNamesValue(after); | String argumentNames = getArgNamesValue(after); | ||||
if (argumentNames != null) { | if (argumentNames != null) { | ||||
struct.unparsedArgumentNames = argumentNames; | struct.unparsedArgumentNames = argumentNames; | ||||
// this/target/args binding | // this/target/args binding | ||||
// exclude the return binding from the pointcut binding since it is | // exclude the return binding from the pointcut binding since it is | ||||
// an extraArg binding | // an extraArg binding | ||||
FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0]; | |||||
FormalBinding[] bindings = FormalBinding.NONE; | |||||
try { | try { | ||||
bindings = (returned == null ? extractBindings(struct) : extractBindings(struct, returned)); | bindings = (returned == null ? extractBindings(struct) : extractBindings(struct, returned)); | ||||
} catch (UnreadableDebugInfoException unreadableDebugInfoException) { | } catch (UnreadableDebugInfoException unreadableDebugInfoException) { | ||||
// this/target/args binding | // this/target/args binding | ||||
// exclude the throwned binding from the pointcut binding since it | // exclude the throwned binding from the pointcut binding since it | ||||
// is an extraArg binding | // is an extraArg binding | ||||
FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0]; | |||||
FormalBinding[] bindings = FormalBinding.NONE; | |||||
try { | try { | ||||
bindings = (thrownFormal == null ? extractBindings(struct) : extractBindings(struct, thrownFormal)); | bindings = (thrownFormal == null ? extractBindings(struct) : extractBindings(struct, thrownFormal)); | ||||
} catch (UnreadableDebugInfoException unreadableDebugInfoException) { | } catch (UnreadableDebugInfoException unreadableDebugInfoException) { | ||||
if (argumentNames != null) { | if (argumentNames != null) { | ||||
struct.unparsedArgumentNames = argumentNames; | struct.unparsedArgumentNames = argumentNames; | ||||
} | } | ||||
FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0]; | |||||
FormalBinding[] bindings = FormalBinding.NONE; | |||||
try { | try { | ||||
bindings = extractBindings(struct); | bindings = extractBindings(struct); | ||||
} catch (UnreadableDebugInfoException unreadableDebugInfoException) { | } catch (UnreadableDebugInfoException unreadableDebugInfoException) { | ||||
} | } | ||||
} | } | ||||
return bindings.toArray(new FormalBinding[] {}); | |||||
return bindings.toArray(FormalBinding.NONE); | |||||
} | } | ||||
// FIXME alex deal with exclude index | // FIXME alex deal with exclude index |
setup.append(fact.createNew(new ObjectType(NameMangler.CFLOW_COUNTER_TYPE))); | setup.append(fact.createNew(new ObjectType(NameMangler.CFLOW_COUNTER_TYPE))); | ||||
setup.append(InstructionFactory.createDup(1)); | setup.append(InstructionFactory.createDup(1)); | ||||
setup.append(fact.createInvoke(NameMangler.CFLOW_COUNTER_TYPE, "<init>", Type.VOID, new Type[0], Constants.INVOKESPECIAL)); | |||||
setup.append(fact.createInvoke(NameMangler.CFLOW_COUNTER_TYPE, "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); | |||||
setup.append(Utility.createSet(fact, cflowCounterField)); | setup.append(Utility.createSet(fact, cflowCounterField)); | ||||
clinit.getBody().insert(setup); | clinit.getBody().insert(setup); |
catchBlockForLiteralLoadingFail.append(InstructionFactory.createDup_1(1)); | catchBlockForLiteralLoadingFail.append(InstructionFactory.createDup_1(1)); | ||||
catchBlockForLiteralLoadingFail.append(InstructionFactory.SWAP); | catchBlockForLiteralLoadingFail.append(InstructionFactory.SWAP); | ||||
catchBlockForLiteralLoadingFail.append(fact.createInvoke("java.lang.Throwable", "getMessage", | catchBlockForLiteralLoadingFail.append(fact.createInvoke("java.lang.Throwable", "getMessage", | ||||
Type.getType(String.class), new Type[] {}, Constants.INVOKEVIRTUAL)); | |||||
Type.getType(String.class), Type.NO_ARGS, Constants.INVOKEVIRTUAL)); | |||||
catchBlockForLiteralLoadingFail.append(fact.createInvoke("java.lang.NoClassDefFoundError", "<init>", Type.VOID, | catchBlockForLiteralLoadingFail.append(fact.createInvoke("java.lang.NoClassDefFoundError", "<init>", Type.VOID, | ||||
new Type[] { Type.getType(String.class) }, Constants.INVOKESPECIAL)); | new Type[] { Type.getType(String.class) }, Constants.INVOKESPECIAL)); | ||||
catchBlockForLiteralLoadingFail.append(InstructionFactory.ATHROW); | catchBlockForLiteralLoadingFail.append(InstructionFactory.ATHROW); |
GenericSignature.ClassSignature genericTypeSig = bcelObjectType.getGenericClassTypeSignature(); | GenericSignature.ClassSignature genericTypeSig = bcelObjectType.getGenericClassTypeSignature(); | ||||
GenericSignature.FormalTypeParameter[] parentFormals = bcelObjectType.getAllFormals(); | GenericSignature.FormalTypeParameter[] parentFormals = bcelObjectType.getAllFormals(); | ||||
GenericSignature.FormalTypeParameter[] typeVars = ((genericTypeSig == null) ? new GenericSignature.FormalTypeParameter[0] | |||||
GenericSignature.FormalTypeParameter[] typeVars = ((genericTypeSig == null) ? GenericSignature.FormalTypeParameter.NONE | |||||
: genericTypeSig.formalTypeParameters); | : genericTypeSig.formalTypeParameters); | ||||
GenericSignature.FormalTypeParameter[] formals = new GenericSignature.FormalTypeParameter[parentFormals.length | GenericSignature.FormalTypeParameter[] formals = new GenericSignature.FormalTypeParameter[parentFormals.length | ||||
+ typeVars.length]; | + typeVars.length]; |
bitflags |= HAS_ANNOTATIONS; | bitflags |= HAS_ANNOTATIONS; | ||||
} | } | ||||
public static final AnnotationAJ[] NO_PARAMETER_ANNOTATIONS = new AnnotationAJ[] {}; | |||||
public void addParameterAnnotation(int param, AnnotationAJ anno) { | public void addParameterAnnotation(int param, AnnotationAJ anno) { | ||||
ensureParameterAnnotationsRetrieved(); | ensureParameterAnnotationsRetrieved(); | ||||
if (parameterAnnotations == NO_PARAMETER_ANNOTATIONXS) { | if (parameterAnnotations == NO_PARAMETER_ANNOTATIONXS) { | ||||
// First time we've added any, so lets set up the array | // First time we've added any, so lets set up the array | ||||
parameterAnnotations = new AnnotationAJ[getArity()][]; | parameterAnnotations = new AnnotationAJ[getArity()][]; | ||||
for (int i = 0; i < getArity(); i++) { | for (int i = 0; i < getArity(); i++) { | ||||
parameterAnnotations[i] = NO_PARAMETER_ANNOTATIONS; | |||||
parameterAnnotations[i] = AnnotationAJ.EMPTY_ARRAY; | |||||
} | } | ||||
} | } | ||||
int existingCount = parameterAnnotations[param].length; | int existingCount = parameterAnnotations[param].length; |
if (pointcuts.size() == 0) { | if (pointcuts.size() == 0) { | ||||
this.pointcuts = ResolvedPointcutDefinition.NO_POINTCUTS; | this.pointcuts = ResolvedPointcutDefinition.NO_POINTCUTS; | ||||
} else { | } else { | ||||
this.pointcuts = pointcuts.toArray(new ResolvedPointcutDefinition[0]); | |||||
this.pointcuts = pointcuts.toArray(ResolvedPointcutDefinition.NO_POINTCUTS); | |||||
} | } | ||||
resolveAnnotationDeclares(l); | resolveAnnotationDeclares(l); | ||||
* until *after* the pointcuts have been resolved. | * until *after* the pointcuts have been resolved. | ||||
*/ | */ | ||||
private void resolveAnnotationDeclares(List<AjAttribute> attributeList) { | private void resolveAnnotationDeclares(List<AjAttribute> attributeList) { | ||||
FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0]; | |||||
FormalBinding[] bindings = FormalBinding.NONE; | |||||
IScope bindingScope = new BindingScope(getResolvedTypeX(), getResolvedTypeX().getSourceContext(), bindings); | IScope bindingScope = new BindingScope(getResolvedTypeX(), getResolvedTypeX().getSourceContext(), bindings); | ||||
for (AjAttribute a : attributeList) { | for (AjAttribute a : attributeList) { | ||||
if (a instanceof AjAttribute.DeclareAttribute) { | if (a instanceof AjAttribute.DeclareAttribute) { | ||||
public GenericSignature.FormalTypeParameter[] getAllFormals() { | public GenericSignature.FormalTypeParameter[] getAllFormals() { | ||||
ensureGenericSignatureUnpacked(); | ensureGenericSignatureUnpacked(); | ||||
if (formalsForResolution == null) { | if (formalsForResolution == null) { | ||||
return new GenericSignature.FormalTypeParameter[0]; | |||||
return FormalTypeParameter.NONE; | |||||
} else { | } else { | ||||
return formalsForResolution; | return formalsForResolution; | ||||
} | } |
if (isPer) { | if (isPer) { | ||||
entrySuccessInstructions.append(fact.createInvoke(munger.getConcreteAspect().getName(), | entrySuccessInstructions.append(fact.createInvoke(munger.getConcreteAspect().getName(), | ||||
NameMangler.PERCFLOW_PUSH_METHOD, Type.VOID, new Type[] {}, Constants.INVOKESTATIC)); | |||||
NameMangler.PERCFLOW_PUSH_METHOD, Type.VOID, Type.NO_ARGS, Constants.INVOKESTATIC)); | |||||
} else { | } else { | ||||
BcelVar[] cflowStateVars = munger.getExposedStateAsBcelVars(false); | BcelVar[] cflowStateVars = munger.getExposedStateAsBcelVars(false); | ||||
entrySuccessInstructions.append(Utility.createGet(fact, cflowField)); | entrySuccessInstructions.append(Utility.createGet(fact, cflowField)); | ||||
// arrayVar.appendLoad(entrySuccessInstructions, fact); | // arrayVar.appendLoad(entrySuccessInstructions, fact); | ||||
entrySuccessInstructions.append(fact.createInvoke(NameMangler.CFLOW_COUNTER_TYPE, "inc", Type.VOID, | entrySuccessInstructions.append(fact.createInvoke(NameMangler.CFLOW_COUNTER_TYPE, "inc", Type.VOID, | ||||
new Type[] {}, Constants.INVOKEVIRTUAL)); | |||||
Type.NO_ARGS, Constants.INVOKEVIRTUAL)); | |||||
} else { | } else { | ||||
BcelVar arrayVar = genTempVar(UnresolvedType.OBJECTARRAY); | BcelVar arrayVar = genTempVar(UnresolvedType.OBJECTARRAY); | ||||
exitInstructions.append(Utility.createGet(fact, cflowField)); | exitInstructions.append(Utility.createGet(fact, cflowField)); | ||||
if (munger.getKind() != AdviceKind.PerCflowEntry && munger.getKind() != AdviceKind.PerCflowBelowEntry | if (munger.getKind() != AdviceKind.PerCflowEntry && munger.getKind() != AdviceKind.PerCflowBelowEntry | ||||
&& munger.getExposedStateAsBcelVars(false).length == 0) { | && munger.getExposedStateAsBcelVars(false).length == 0) { | ||||
exitInstructions.append(fact.createInvoke(NameMangler.CFLOW_COUNTER_TYPE, "dec", Type.VOID, new Type[] {}, | |||||
exitInstructions.append(fact.createInvoke(NameMangler.CFLOW_COUNTER_TYPE, "dec", Type.VOID, Type.NO_ARGS, | |||||
Constants.INVOKEVIRTUAL)); | Constants.INVOKEVIRTUAL)); | ||||
} else { | } else { | ||||
exitInstructions.append(fact.createInvoke(NameMangler.CFLOW_STACK_TYPE, "pop", Type.VOID, new Type[] {}, | |||||
exitInstructions.append(fact.createInvoke(NameMangler.CFLOW_STACK_TYPE, "pop", Type.VOID, Type.NO_ARGS, | |||||
Constants.INVOKEVIRTUAL)); | Constants.INVOKEVIRTUAL)); | ||||
} | } | ||||
return exitInstructions; | return exitInstructions; |
Type fieldType = BcelWorld.makeBcelType(aspectType); | Type fieldType = BcelWorld.makeBcelType(aspectType); | ||||
LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC, fieldType, NameMangler.perObjectInterfaceGet(aspectType), | LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC, fieldType, NameMangler.perObjectInterfaceGet(aspectType), | ||||
new Type[0], new String[0], gen); | |||||
Type.NO_ARGS, new String[0], gen); | |||||
InstructionList il = new InstructionList(); | InstructionList il = new InstructionList(); | ||||
InstructionFactory fact = gen.getFactory(); | InstructionFactory fact = gen.getFactory(); | ||||
il.append(InstructionConstants.ALOAD_0); | il.append(InstructionConstants.ALOAD_0); | ||||
// "public com_blah_SecurityAspect ajc$com_blah_SecurityAspect$localAspectOf()" | // "public com_blah_SecurityAspect ajc$com_blah_SecurityAspect$localAspectOf()" | ||||
Type fieldType = BcelWorld.makeBcelType(aspectType); | Type fieldType = BcelWorld.makeBcelType(aspectType); | ||||
LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC | Modifier.STATIC, fieldType, | LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC | Modifier.STATIC, fieldType, | ||||
NameMangler.perTypeWithinLocalAspectOf(aspectType), new Type[0], new String[0], gen); | |||||
NameMangler.perTypeWithinLocalAspectOf(aspectType), Type.NO_ARGS, new String[0], gen); | |||||
InstructionList il = new InstructionList(); | InstructionList il = new InstructionList(); | ||||
// PTWIMPL ?? Should check if it is null and throw | // PTWIMPL ?? Should check if it is null and throw | ||||
// NoAspectBoundException | // NoAspectBoundException |
return gen; | return gen; | ||||
} | } | ||||
} | } | ||||
LazyMethodGen clinit = new LazyMethodGen(Modifier.STATIC, Type.VOID, "<clinit>", new Type[0], NO_STRINGS, this); | |||||
LazyMethodGen clinit = new LazyMethodGen(Modifier.STATIC, Type.VOID, "<clinit>", Type.NO_ARGS, NO_STRINGS, this); | |||||
clinit.getBody().insert(InstructionConstants.RETURN); | clinit.getBody().insert(InstructionConstants.RETURN); | ||||
methodGens.add(clinit); | methodGens.add(clinit); | ||||
return clinit; | return clinit; |
*/ | */ | ||||
public final class LazyMethodGen implements Traceable { | public final class LazyMethodGen implements Traceable { | ||||
private static final AnnotationAJ[] NO_ANNOTATIONAJ = new AnnotationAJ[] {}; | |||||
private int modifiers; | private int modifiers; | ||||
private Type returnType; | private Type returnType; | ||||
private final String name; | private final String name; | ||||
newParameterAnnotations[i] = new AnnotationAJ[1]; | newParameterAnnotations[i] = new AnnotationAJ[1]; | ||||
newParameterAnnotations[i][0] = anno; | newParameterAnnotations[i][0] = anno; | ||||
} else { | } else { | ||||
newParameterAnnotations[i] = NO_ANNOTATIONAJ; | |||||
newParameterAnnotations[i] = AnnotationAJ.EMPTY_ARRAY; | |||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
public AnnotationAJ[] getAnnotations() { | public AnnotationAJ[] getAnnotations() { | ||||
initialize(); | initialize(); | ||||
if (memberView == null && newAnnotations!=null && newAnnotations.size()!=0) { | if (memberView == null && newAnnotations!=null && newAnnotations.size()!=0) { | ||||
return newAnnotations.toArray(new AnnotationAJ[0]); | |||||
return newAnnotations.toArray(AnnotationAJ.EMPTY_ARRAY); | |||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
if (enclosingClass != null && enclosingClass.getType() != null) { | if (enclosingClass != null && enclosingClass.getType() != null) { | ||||
context = enclosingClass.getType().getSourceContext(); | context = enclosingClass.getType().getSourceContext(); | ||||
} | } | ||||
List<AjAttribute> as = Utility.readAjAttributes(getClassName(), attributes.toArray(new Attribute[] {}), context, null, weaverVersion, | |||||
List<AjAttribute> as = Utility.readAjAttributes(getClassName(), attributes.toArray(Attribute.NoAttributes), context, null, weaverVersion, | |||||
new BcelConstantPoolReader(this.enclosingClass.getConstantPool())); | new BcelConstantPoolReader(this.enclosingClass.getConstantPool())); | ||||
if (!as.isEmpty()) { | if (!as.isEmpty()) { | ||||
out.println(" " + as.get(0)); // XXX assuming exactly one | out.println(" " + as.get(0)); // XXX assuming exactly one |
Type jlClass = BcelWorld.makeBcelType(UnresolvedType.JL_CLASS); | Type jlClass = BcelWorld.makeBcelType(UnresolvedType.JL_CLASS); | ||||
Type jlaAnnotation = BcelWorld.makeBcelType(UnresolvedType.ANNOTATION); | Type jlaAnnotation = BcelWorld.makeBcelType(UnresolvedType.ANNOTATION); | ||||
il.append(target.createLoad(fact)); | il.append(target.createLoad(fact)); | ||||
il.append(fact.createInvoke("java/lang/Object", "getClass", jlClass, new Type[] {}, Constants.INVOKEVIRTUAL)); | |||||
il.append(fact.createInvoke("java/lang/Object", "getClass", jlClass, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); | |||||
il.append(fact.createConstant(new ObjectType(toType.getName()))); | il.append(fact.createConstant(new ObjectType(toType.getName()))); | ||||
il.append(fact.createInvoke("java/lang/Class", "getAnnotation", jlaAnnotation, new Type[] { jlClass }, | il.append(fact.createInvoke("java/lang/Class", "getAnnotation", jlaAnnotation, new Type[] { jlClass }, | ||||
Constants.INVOKEVIRTUAL)); | Constants.INVOKEVIRTUAL)); |
import org.aspectj.apache.bcel.classfile.JavaClass; | import org.aspectj.apache.bcel.classfile.JavaClass; | ||||
import org.aspectj.apache.bcel.classfile.LocalVariable; | import org.aspectj.apache.bcel.classfile.LocalVariable; | ||||
import org.aspectj.apache.bcel.classfile.LocalVariableTable; | import org.aspectj.apache.bcel.classfile.LocalVariableTable; | ||||
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; | |||||
import org.aspectj.apache.bcel.util.ClassLoaderRepository; | import org.aspectj.apache.bcel.util.ClassLoaderRepository; | ||||
import org.aspectj.apache.bcel.util.NonCachingClassLoaderRepository; | import org.aspectj.apache.bcel.util.NonCachingClassLoaderRepository; | ||||
import org.aspectj.apache.bcel.util.Repository; | import org.aspectj.apache.bcel.util.Repository; | ||||
// memory. | // memory. | ||||
try { | try { | ||||
JavaClass jc = bcelRepository.loadClass(onMember.getDeclaringClass()); | JavaClass jc = bcelRepository.loadClass(onMember.getDeclaringClass()); | ||||
org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[] anns = new org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[0]; | |||||
org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[] anns = AnnotationGen.NO_ANNOTATIONS; | |||||
if (onMember instanceof Method) { | if (onMember instanceof Method) { | ||||
org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method) onMember); | org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method) onMember); | ||||
if (bcelMethod == null) { | if (bcelMethod == null) { | ||||
bcelRepository.clear(); | bcelRepository.clear(); | ||||
// OPTIMIZE make constant 0 size array for sharing | // OPTIMIZE make constant 0 size array for sharing | ||||
if (anns == null) | if (anns == null) | ||||
anns = new org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[0]; | |||||
anns = AnnotationGen.NO_ANNOTATIONS; | |||||
// convert to our Annotation type | // convert to our Annotation type | ||||
for (org.aspectj.apache.bcel.classfile.annotation.AnnotationGen ann : anns) { | for (org.aspectj.apache.bcel.classfile.annotation.AnnotationGen ann : anns) { | ||||
if (ann.getTypeSignature().equals(ofType.getSignature())) { | if (ann.getTypeSignature().equals(ofType.getSignature())) { |
private ResolvedMember createGenericFieldMember(Field forField) { | private ResolvedMember createGenericFieldMember(Field forField) { | ||||
ReflectionBasedResolvedMemberImpl ret = new ReflectionBasedResolvedMemberImpl(org.aspectj.weaver.Member.FIELD, | ReflectionBasedResolvedMemberImpl ret = new ReflectionBasedResolvedMemberImpl(org.aspectj.weaver.Member.FIELD, | ||||
getGenericResolvedType(), forField.getModifiers(), typeConverter.fromType(forField.getType()), forField.getName(), | getGenericResolvedType(), forField.getModifiers(), typeConverter.fromType(forField.getType()), forField.getName(), | ||||
new UnresolvedType[0], forField); | |||||
UnresolvedType.NONE, forField); | |||||
ret.setAnnotationFinder(this.annotationFinder); | ret.setAnnotationFinder(this.annotationFinder); | ||||
ret.setGenericSignatureInformationProvider(new Java15GenericSignatureInformationProvider(this.getWorld())); | ret.setGenericSignatureInformationProvider(new Java15GenericSignatureInformationProvider(this.getWorld())); | ||||
return ret; | return ret; |
Type[] bounds = tv.getBounds(); | Type[] bounds = tv.getBounds(); | ||||
ResolvedType[] resBounds = fromTypes(bounds); | ResolvedType[] resBounds = fromTypes(bounds); | ||||
ResolvedType upperBound = resBounds[0]; | ResolvedType upperBound = resBounds[0]; | ||||
ResolvedType[] additionalBounds = new ResolvedType[0]; | |||||
ResolvedType[] additionalBounds = ResolvedType.EMPTY_RESOLVED_TYPE_ARRAY; | |||||
if (resBounds.length > 1) { | if (resBounds.length > 1) { | ||||
additionalBounds = new ResolvedType[resBounds.length - 1]; | additionalBounds = new ResolvedType[resBounds.length - 1]; | ||||
System.arraycopy(resBounds, 1, additionalBounds, 0, additionalBounds.length); | System.arraycopy(resBounds, 1, additionalBounds, 0, additionalBounds.length); |