diff options
author | Andy Clement <aclement@pivotal.io> | 2018-05-25 12:49:56 -0700 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2018-05-25 12:49:56 -0700 |
commit | a024df9675409344ecdf232d6ac3a283602323d5 (patch) | |
tree | 8e26353a70d78a92515bc53aabbe3ef1bfc4e581 /weaver | |
parent | e5300c899245d98cbb97327aa6a879d379706607 (diff) | |
download | aspectj-a024df9675409344ecdf232d6ac3a283602323d5.tar.gz aspectj-a024df9675409344ecdf232d6ac3a283602323d5.zip |
Initial cut at bug 535086 - pertypewithin and non vis types
In this version unless you specify an aspect is privileged then the
pertypewithin clause will not match types not visible from the aspect
(private types or default vis types in another package)
Debating whether to change this to not require privileged.
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelShadow.java | 17 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java | 4 |
2 files changed, 16 insertions, 5 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index 6ba22ed97..2e8d3ab6b 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -1129,6 +1129,7 @@ public class BcelShadow extends Shadow { return getThisJoinPointStaticPartBcelVar(false); } + @Override public BcelVar getThisAspectInstanceVar(ResolvedType aspectType) { return new AspectInstanceVar(aspectType); } @@ -1995,16 +1996,24 @@ public class BcelShadow extends Shadow { * Causes the aspect instance to be *set* for later retrievable through localAspectof()/aspectOf() */ public void weavePerTypeWithinAspectInitialization(final BcelAdvice munger, UnresolvedType t) { - - if (t.resolve(world).isInterface()) { - return; // Don't initialize statics in + ResolvedType tResolved = t.resolve(world); + if (tResolved.isInterface()) { + return; // Don't initialize statics in interfaces + } + ResolvedType aspectRT = munger.getConcreteAspect(); + BcelWorld.getBcelObjectType(aspectRT); + + // Although matched, if the visibility rules prevent the aspect from seeing this type, don't + // insert any code (easier to do it here than try to affect the matching logic, unfortunately) + if (!(tResolved.canBeSeenBy(aspectRT) || aspectRT.isPrivilegedAspect())) { + return; } + final InstructionFactory fact = getFactory(); InstructionList entryInstructions = new InstructionList(); InstructionList entrySuccessInstructions = new InstructionList(); - BcelWorld.getBcelObjectType(munger.getConcreteAspect()); String aspectname = munger.getConcreteAspect().getName(); String ptwField = NameMangler.perTypeWithinFieldForTarget(munger.getConcreteAspect()); diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java index c82c352ae..b92760fe9 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -829,7 +829,9 @@ public class BcelTypeMunger extends ConcreteTypeMunger { // e.g ajc$com_blah_SecurityAspect$ptwAspectInstance FieldGen fg = makeFieldGen(gen, AjcMemberMaker.perTypeWithinField(gen.getType(), aspectType)); gen.addField(fg, getSourceLocation()); - + if (!gen.getType().canBeSeenBy(aspectType) && aspectType.isPrivilegedAspect()) { + gen.forcePublic(); + } // Add an accessor for this new field, the // ajc$<aspectname>$localAspectOf() method // e.g. |