declareDominates.add(declare);
} else if (declare instanceof DeclareParents) {
DeclareParents dp = (DeclareParents)declare;
- for (Iterator i = dp.getParents().collectAccessTypeMungers(world).iterator(); i.hasNext(); ) {
- addTypeMunger(world.concreteTypeMunger((PrivilegedAccessMunger)i.next(), inAspect));
- }
+ exposeTypes(dp.getParents().getExactTypes());
declareParents.add(dp);
} else if (declare instanceof DeclareSoft) {
DeclareSoft d = (DeclareSoft)declare;
}
}
+ public void exposeTypes(Collection typesToExpose) {
+ for (Iterator i = typesToExpose.iterator(); i.hasNext(); ) {
+ exposeType((TypeX)i.next());
+ }
+ }
+
+ public void exposeType(TypeX typeToExpose) {
+ if (typeToExpose == ResolvedTypeX.MISSING) return;
+
+ ResolvedMember member = new ResolvedMember(
+ Member.STATIC_INITIALIZATION, typeToExpose, 0, ResolvedTypeX.VOID, "", TypeX.NONE);
+ addTypeMunger(world.concreteTypeMunger(
+ new PrivilegedAccessMunger(member), inAspect));
+ }
+
public void addPrivilegedAccesses(Collection accessedMembers) {
for (Iterator i = accessedMembers.iterator(); i.hasNext(); ) {
addPrivilegedAccess( (ResolvedMember)i.next() );
}
public FuzzyBoolean match(Shadow shadow) {
- int n = shadow.getArgCount();
- TypeX[] argTypes = new TypeX[n];
- for (int i=0; i < n; i++) {
- argTypes[i] = shadow.getArgType(i);
- }
FuzzyBoolean ret =
- arguments.matches(shadow.getIWorld().resolve(argTypes), TypePattern.DYNAMIC);
+ arguments.matches(shadow.getIWorld().resolve(shadow.getArgTypes()), TypePattern.DYNAMIC);
return ret;
}
public Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) {
- return new ArgsPointcut(arguments.resolveReferences(bindings));
+ TypePatternList args = arguments.resolveReferences(bindings);
+ if (inAspect.crosscuttingMembers != null) {
+ inAspect.crosscuttingMembers.exposeTypes(args.getExactTypes());
+ }
+ return new ArgsPointcut(args);
}
private Test findResidueNoEllipsis(Shadow shadow, ExposedState state, TypePattern[] patterns) {
int len = shadow.getArgCount();
//System.err.println("boudn to : " + len + ", " + patterns.length);
if (patterns.length != len) {
- throw new RuntimeException("this should never happen");
- //return Literal.FALSE; //??? this should never happen
+ return Literal.FALSE;
}
Test ret = Literal.TRUE;
}
public Test findResidue(Shadow shadow, ExposedState state) {
+ if (arguments.matches(shadow.getIWorld().resolve(shadow.getArgTypes()), TypePattern.DYNAMIC).alwaysFalse()) {
+ return Literal.FALSE;
+ }
int ellipsisCount = arguments.ellipsisCount;
if (ellipsisCount == 0) {
return findResidueNoEllipsis(shadow, state, arguments.getTypePatterns());
}
public Pointcut concretize1(ResolvedTypeX inAspect, IntMap bindings) {
- return new ThisOrTargetPointcut(isThis, type.remapAdviceFormals(bindings));
+ TypePattern newType = type.remapAdviceFormals(bindings);
+ if (inAspect.crosscuttingMembers != null) {
+ inAspect.crosscuttingMembers.exposeType(newType.getExactType());
+ }
+
+ return new ThisOrTargetPointcut(isThis, newType);
}
}
return typePatterns;
}
- public Collection collectAccessTypeMungers(World world) {
+ public Collection getExactTypes() {
ArrayList ret = new ArrayList();
for (int i=0; i<typePatterns.length; i++) {
TypeX t = typePatterns[i].getExactType();
- ResolvedTypeX rt = t.resolve(world);
- if (!Modifier.isPublic(rt.getModifiers())) {
- ret.add(new PrivilegedAccessMunger(new ResolvedMember(
- Member.STATIC_INITIALIZATION, rt, 0, ResolvedTypeX.VOID, "", TypeX.NONE
- )));
- }
+ if (t != ResolvedTypeX.MISSING) ret.add(t);
}
return ret;
}