(implement @AspectJ ITD @DeclareParents and @DeclareImplements changed AjType as ITD field is meaningless (as @AJ ITD is interface driven))tags/V1_5_0RC1
@@ -671,21 +671,6 @@ public class AjTypeImpl<T> implements AjType<T> { | |||
} | |||
} | |||
} | |||
// Class<?>[] classes = clazz.getDeclaredClasses(); | |||
// for(Class<?> c : classes) { | |||
// if (c.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) { | |||
// if (c.getInterfaces().length == 0) continue; | |||
// AjType<?> targetType = AjTypeSystem.getAjType((Class<?>)c.getInterfaces()[0]); | |||
// Method[] meths = c.getDeclaredMethods(); | |||
// for (Method m : meths) { | |||
// if (!Modifier.isPublic(m.getModifiers()) && publicOnly) continue; | |||
// InterTypeMethodDeclaration itdm = | |||
// new InterTypeMethodDeclarationImpl( | |||
// this,targetType,m); | |||
// toList.add(itdm); | |||
// } | |||
// } | |||
// } | |||
} | |||
} | |||
@@ -693,38 +678,8 @@ public class AjTypeImpl<T> implements AjType<T> { | |||
return; | |||
//AV: I think it is meaningless | |||
//@AJ decp is interface driven ie no field | |||
// 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)) { | |||
// for (Field itdF : f.getType().getDeclaredFields()) { | |||
// if (!Modifier.isPublic(itdF.getModifiers()) && publicOnly) continue; | |||
// InterTypeFieldDeclaration itdf = new InterTypeFieldDeclarationImpl( | |||
// this, AjTypeSystem.getAjType(f.getType()), itdF | |||
// ); | |||
// toList.add(itdf); | |||
// } | |||
// } | |||
// } | |||
//---old impl. | |||
// Class<?>[] classes = clazz.getDeclaredClasses(); | |||
// for(Class<?> c : classes) { | |||
// if (c.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) { | |||
// if (c.getInterfaces().length == 0) continue; | |||
// AjType<?> targetType = AjTypeSystem.getAjType((Class<?>)c.getInterfaces()[0]); | |||
// Field[] fields = c.getDeclaredFields(); | |||
// for (Field f : fields) { | |||
// if (!Modifier.isPublic(f.getModifiers()) && publicOnly) continue; | |||
// InterTypeFieldDeclaration itdf = | |||
// new InterTypeFieldDeclarationImpl( | |||
// this,targetType,f); | |||
// toList.add(itdf); | |||
// } | |||
// } | |||
// } | |||
// } | |||
} | |||
/* (non-Javadoc) | |||
* @see org.aspectj.lang.reflect.AjType#getDeclaredITDConstructor(java.lang.Class, java.lang.Class...) | |||
*/ | |||
@@ -1021,22 +976,6 @@ public class AjTypeImpl<T> implements AjType<T> { | |||
toList.add(decp); | |||
} | |||
} | |||
// | |||
// Class<?>[] classes = clazz.getDeclaredClasses(); | |||
// for (Class<?> c : classes) { | |||
// if (c.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) { | |||
// org.aspectj.lang.annotation.DeclareParents ann = c.getAnnotation(org.aspectj.lang.annotation.DeclareParents.class); | |||
// if (c.getInterfaces().length == 0) continue; | |||
// String parentType = c.getInterfaces()[0].getName(); | |||
// DeclareParentsImpl decp = new DeclareParentsImpl( | |||
// ann.value(), | |||
// parentType, | |||
// false, | |||
// this | |||
// ); | |||
// toList.add(decp); | |||
// } | |||
// } | |||
} | |||
/* (non-Javadoc) |
@@ -21,12 +21,34 @@ import java.io.IOException; | |||
import java.util.Set; | |||
import java.util.Iterator; | |||
/** | |||
* Type munger for @AspectJ ITD declare parents ie with an interface AND an implementation. | |||
* Given the aspect that has a field public static Interface fieldI = ... // impl. | |||
* we will weave in the Interface' methods and delegate to the aspect public static field fieldI | |||
* | |||
* Note: this munger DOES NOT handles the interface addition to the target classes - a regular Parent kinded munger | |||
* must be added in coordination. | |||
*/ | |||
public class MethodDelegateTypeMunger extends ResolvedTypeMunger { | |||
/** | |||
* The field in the aspect that hosts the mixin instance | |||
*/ | |||
private final ResolvedMember aspectFieldDelegate; | |||
/** | |||
* Type pattern this munger applies to | |||
*/ | |||
private final TypePattern typePattern; | |||
/** | |||
* Construct a new type munger for @AspectJ ITD | |||
* | |||
* @param signature | |||
* @param aspect | |||
* @param fieldName | |||
* @param typePattern | |||
*/ | |||
public MethodDelegateTypeMunger(ResolvedMember signature, ResolvedType aspect, String fieldName, TypePattern typePattern) { | |||
super(MethodDelegate, signature); | |||
this.typePattern = typePattern; | |||
@@ -50,14 +72,6 @@ public class MethodDelegateTypeMunger extends ResolvedTypeMunger { | |||
return aspectFieldDelegate; | |||
} | |||
// public ResolvedMember getInterMethodBody(UnresolvedType aspectType) { | |||
// return AjcMemberMaker.interMethodBody(signature, aspectType); | |||
// } | |||
// | |||
// public ResolvedMember getInterMethodDispatcher(UnresolvedType aspectType) { | |||
// return AjcMemberMaker.interMethodDispatcher(signature, aspectType); | |||
// } | |||
public void write(DataOutputStream s) throws IOException { | |||
;//FIXME AVITD needed as changes public signature throw new RuntimeException("unimplemented"); | |||
} | |||
@@ -69,14 +83,15 @@ public class MethodDelegateTypeMunger extends ResolvedTypeMunger { | |||
// ResolvedTypeMunger munger = new MethodDelegateTypeMunger(rmi, superMethodsCalled); | |||
// if (sLoc != null) munger.setSourceLocation(sLoc); | |||
// return munger; | |||
// } | |||
// | |||
// public ResolvedMember getMatchingSyntheticMember(Member member, ResolvedType aspectType) { | |||
// ResolvedMember ret = AjcMemberMaker.interMethodDispatcher(getSignature(), aspectType); | |||
// if (ResolvedType.matches(ret, member)) return getSignature(); | |||
// return super.getMatchingSyntheticMember(member, aspectType); | |||
// } | |||
/** | |||
* Match based on given type pattern, only classes can be matched | |||
* | |||
* @param matchType | |||
* @param aspectType | |||
* @return true if match | |||
*/ | |||
public boolean matches(ResolvedType matchType, ResolvedType aspectType) { | |||
// match only on class | |||
if (matchType.isEnum() || matchType.isInterface() || matchType.isAnnotation()) { | |||
@@ -86,6 +101,11 @@ public class MethodDelegateTypeMunger extends ResolvedTypeMunger { | |||
return typePattern.matchesStatically(matchType); | |||
} | |||
/** | |||
* Needed for reweavable | |||
* | |||
* @return true | |||
*/ | |||
public boolean changesPublicSignature() { | |||
return true; | |||
} |
@@ -444,30 +444,8 @@ public class AtAjAttributes { | |||
* @return list of AjAttributes, always empty for now | |||
*/ | |||
public static List readAj5FieldAttributes(Field field, BcelField bField, ResolvedType type, ISourceContext context, IMessageHandler msgHandler) { | |||
//TODO use ? if (field.getName().startsWith(NameMangler.PREFIX)) return Collections.EMPTY_LIST; // already dealt with by ajc... | |||
// | |||
// // bypass primitive type fields - useless for @DeclareParents/Implements (interface) | |||
// if (bField.getType().isPrimitiveType()) return Collections.EMPTY_LIST; | |||
// | |||
// AjAttributeFieldStruct struct = new AjAttributeFieldStruct(field, bField, type, context, msgHandler); | |||
// Attribute[] attributes = field.getAttributes(); | |||
// | |||
// boolean hasAtAspectJAnnotation = false; | |||
// for (int i = 0; i < attributes.length; i++) { | |||
// Attribute attribute = attributes[i]; | |||
// try { | |||
// if (acceptAttribute(attribute)) { | |||
// RuntimeAnnotations rvs = (RuntimeAnnotations) attribute; | |||
// hasAtAspectJAnnotation = hasAtAspectJAnnotation || handleDeclareImplementsAnnotation( | |||
// rvs, struct//, preResolvedPointcut//FIXME add in src layer | |||
// ); | |||
// } | |||
// } catch (Exception e) { | |||
// | |||
// } | |||
// } | |||
// | |||
return Collections.EMPTY_LIST;//struct.ajAttributes; | |||
// Note: field annotation are for ITD and DEOW - processed at class level directly | |||
return Collections.EMPTY_LIST; | |||
} | |||
/** |
@@ -235,7 +235,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger { | |||
boolean satisfiedByITD = false; | |||
for (Iterator ii = newParentTarget.getType().getInterTypeMungersIncludingSupers().iterator(); ii.hasNext(); ) { | |||
ConcreteTypeMunger m = (ConcreteTypeMunger)ii.next(); | |||
if (m.getMunger().getKind() == ResolvedTypeMunger.Method) {//FIXME AVITD was instanceof | |||
if (m.getMunger().getKind() == ResolvedTypeMunger.Method) { | |||
ResolvedMember sig = m.getSignature(); | |||
if (!Modifier.isAbstract(sig.getModifiers())) { | |||
if (ResolvedType | |||
@@ -246,7 +246,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger { | |||
} | |||
} | |||
} else if (m.getMunger().getKind() == ResolvedTypeMunger.MethodDelegate) { | |||
satisfiedByITD = true;//FIXME AVITD that should be enough, no need to check more | |||
satisfiedByITD = true;//AV - that should be enough, no need to check more | |||
} | |||
} | |||
if (!satisfiedByITD) { | |||
@@ -973,65 +973,6 @@ public class BcelTypeMunger extends ConcreteTypeMunger { | |||
return true; | |||
} | |||
return false; | |||
// else if (onInterface && !Modifier.isAbstract(unMangledInterMethod.getModifiers())) { | |||
// | |||
// // This means the 'gen' should be the top most implementor | |||
// // - if it is *not* then something went wrong after we worked | |||
// // out that it was the top most implementor (see pr49657) | |||
// if (!gen.getType().isTopmostImplementor(onType)) { | |||
// ResolvedType rtx = gen.getType().getTopmostImplementor(onType); | |||
// if (!rtx.isExposedToWeaver()) { | |||
// ISourceLocation sLoc = munger.getSourceLocation(); | |||
// weaver.getWorld().getMessageHandler().handleMessage(MessageUtil.error( | |||
// WeaverMessages.format(WeaverMessages.ITD_NON_EXPOSED_IMPLEMENTOR,rtx,getAspectType().getName()), | |||
// (sLoc==null?getAspectType().getSourceLocation():sLoc))); | |||
// } else { | |||
// // XXX what does this state mean? | |||
// // We have incorrectly identified what is the top most implementor and its not because | |||
// // a type wasn't exposed to the weaver | |||
// } | |||
// return false; | |||
// } else { | |||
// | |||
// ResolvedMember mangledInterMethod = | |||
// AjcMemberMaker.interMethod(unMangledInterMethod, aspectType, false); | |||
// | |||
// LazyMethodGen mg = makeMethodGen(gen, mangledInterMethod); | |||
// if (mungingInterface) { | |||
// // we want the modifiers of the ITD to be used for all *implementors* of the | |||
// // interface, but the method itself we add to the interface must be public abstract | |||
// mg.setAccessFlags(Modifier.PUBLIC | Modifier.ABSTRACT); | |||
// } | |||
// | |||
// Type[] paramTypes = BcelWorld.makeBcelTypes(mangledInterMethod.getParameterTypes()); | |||
// Type returnType = BcelWorld.makeBcelType(mangledInterMethod.getReturnType()); | |||
// | |||
// InstructionList body = mg.getBody(); | |||
// InstructionFactory fact = gen.getFactory(); | |||
// int pos = 0; | |||
// | |||
// if (!mangledInterMethod.isStatic()) { | |||
// body.append(InstructionFactory.createThis()); | |||
// pos++; | |||
// } | |||
// for (int i = 0, len = paramTypes.length; i < len; i++) { | |||
// Type paramType = paramTypes[i]; | |||
// body.append(InstructionFactory.createLoad(paramType, pos)); | |||
// pos+=paramType.getSize(); | |||
// } | |||
// body.append(Utility.createInvoke(fact, weaver.getWorld(), interMethodBody)); | |||
// body.append(InstructionFactory.createReturn(returnType)); | |||
// mg.definingType = onType; | |||
// | |||
// weaver.addOrReplaceLazyMethodGen(mg); | |||
// | |||
// addNeededSuperCallMethods(weaver, onType, munger.getSuperMethodsCalled()); | |||
// | |||
// return true; | |||
// } | |||
// } else { | |||
// return false; | |||
// } | |||
} | |||
private ResolvedMember getRealMemberForITDFromAspect(ResolvedType aspectType,ResolvedMember lookingFor,boolean isCtorRelated) { |