for (Field f : clazz.getDeclaredFields()) {
if (!f.getType().isInterface()) continue;
if (!Modifier.isPublic(f.getModifiers()) || !Modifier.isStatic(f.getModifiers())) continue;
- if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
- Class itdSource = f.getType();
- try {
- itdSource = f.get(null).getClass();
- } catch (IllegalAccessException ex) {
- //
- }
- for (Method itdM : itdSource.getDeclaredMethods()) {
+ if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
+ for (Method itdM : f.getType().getDeclaredMethods()) {
if (!Modifier.isPublic(itdM.getModifiers()) && publicOnly) continue;
InterTypeMethodDeclaration itdm = new InterTypeMethodDeclarationImpl(
- this, AjTypeSystem.getAjType(f.getType()), itdM
+ this, AjTypeSystem.getAjType(f.getType()), itdM,
+ Modifier.PUBLIC
);
toList.add(itdm);
}
private void addAnnotationStyleITDFields(List<InterTypeFieldDeclaration> toList, boolean publicOnly) {
//AV: I think it is meaningless
//@AJ decp is interface driven ie no field
- // AMC: private fields in the mixin type should show as ITDs private to the aspect...
- if (isAspect()) {
- for (Field f : clazz.getDeclaredFields()) {
- if (!f.getType().isInterface()) continue;
- if (!Modifier.isPublic(f.getModifiers()) || !Modifier.isStatic(f.getModifiers())) continue;
- if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) {
- Class itdSource = f.getType();
- try {
- itdSource = f.get(null).getClass();
- } catch (IllegalAccessException ex) {
- //
- }
- for (Field itdF : itdSource.getDeclaredFields()) {
- if (!Modifier.isPublic(itdF.getModifiers()) && publicOnly) continue;
- InterTypeFieldDeclaration itdf = new InterTypeFieldDeclarationImpl(
- this, AjTypeSystem.getAjType(f.getType()), itdF
- );
- toList.add(itdf);
- }
- }
- }
- }
+ return;
}
/* (non-Javadoc)
this.baseMethod = itdInterMethod;
}
- public InterTypeMethodDeclarationImpl(AjType<?> decType, AjType<?> targetType, Method base) {
- super(decType,targetType,base.getModifiers());
+ public InterTypeMethodDeclarationImpl(AjType<?> decType, AjType<?> targetType, Method base, int modifiers) {
+ super(decType,targetType,modifiers);
this.parameterAdjustmentFactor = 0;
this.name = base.getName();
this.baseMethod = base;
class C {}
-interface I{}
+interface I{
+
+ int getX();
+
+ void setX(int x);
+
+}
class Impl implements I {
private void testDeclaredInterTypeFields(AjType<AtAspectJDeclareParents> ajType) {
InterTypeFieldDeclaration[] itdfs = ajType.getDeclaredITDFields();
- assertEquals(1,itdfs.length,"number of declared ITD fields");
- System.out.println(itdfs[0]);
- try {
- InterTypeFieldDeclaration shouldFind = ajType.getDeclaredITDField("x",AjTypeSystem.getAjType(I.class));
- System.out.println(shouldFind);
- } catch (NoSuchFieldException ex) {
- throw new RuntimeException("getITDField failed");
- }
- try {
- ajType.getDeclaredITDField("p",AjTypeSystem.getAjType(C.class));
- throw new RuntimeException("failed to fail in getting ITDField");
- } catch (NoSuchFieldException ex) {
- // good!
- }
-
+ assertEquals(0,itdfs.length,"number of declared ITD fields");
}
private void testInterTypeFields(AjType<AtAspectJDeclareParents> ajType) {
<line text="public int I.getX()"/>
<line text="public void I.setX(int)"/>
<line text="public int I.getX()"/>
- <line text="private int I.x"/>
- <line text="private int I.x"/>
</stdout>
</run>
</ajc-test>
// else return FuzzyBoolean.MAYBE;
}
- // annotations match on the *subject*
- if (!matchesAnnotations(aMember,inAWorld).alwaysTrue()) {
- return FuzzyBoolean.NO;
- }
+ FuzzyBoolean matchesIgnoringAnnotations = FuzzyBoolean.YES;
if (kind == Member.STATIC_INITIALIZATION) {
- return matchesExactlyStaticInitialization(aMember, inAWorld);
+ matchesIgnoringAnnotations = matchesExactlyStaticInitialization(aMember, inAWorld);
} else if (kind == Member.FIELD) {
- return matchesExactlyField(aMember,inAWorld);
+ matchesIgnoringAnnotations = matchesExactlyField(aMember,inAWorld);
} else if (kind == Member.METHOD) {
- return matchesExactlyMethod(aMember,inAWorld);
+ matchesIgnoringAnnotations = matchesExactlyMethod(aMember,inAWorld);
} else if (kind == Member.CONSTRUCTOR) {
- return matchesExactlyConstructor(aMember, inAWorld);
+ matchesIgnoringAnnotations = matchesExactlyConstructor(aMember, inAWorld);
+ }
+ if (matchesIgnoringAnnotations.alwaysFalse()) return FuzzyBoolean.NO;
+
+ // annotations match on the *subject*
+ if (!matchesAnnotations(aMember,inAWorld).alwaysTrue()) {
+ return FuzzyBoolean.NO;
} else {
- return FuzzyBoolean.YES;
+ return matchesIgnoringAnnotations;
}
}