diff options
author | Semyon Danilov <samvimes@yandex.ru> | 2019-07-24 23:57:17 +0300 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2019-09-10 10:27:03 -0700 |
commit | d8821e28d6e4b59ab451dc166e96698646a6e750 (patch) | |
tree | 0336e70abf46f43a14d5830cc4bd3bc1f0e005d3 /weaver/src/main | |
parent | 226df51a0cf61f8a1de5d1a7973de7f2fb7c0ff4 (diff) | |
download | aspectj-d8821e28d6e4b59ab451dc166e96698646a6e750.tar.gz aspectj-d8821e28d6e4b59ab451dc166e96698646a6e750.zip |
- dont't weave synthetic enum helper method for switch
- add test for switch on enum with around all advice
Signed-off-by: Semyon Danilov <samvimes@yandex.ru>
Diffstat (limited to 'weaver/src/main')
-rw-r--r-- | weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java index 83919ed50..80d704891 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.Objects; import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.BootstrapMethods; @@ -93,6 +94,8 @@ class BcelClassWeaver implements IClassWeaver { private static Trace trace = TraceFactory.getTraceFactory().getTrace(BcelClassWeaver.class); + private static final String SWITCH_TABLE_SYNTHETIC_METHOD_PREFIX = "$SWITCH_TABLE$"; + public static boolean weave(BcelWorld world, LazyClassGen clazz, List<ShadowMunger> shadowMungers, List<ConcreteTypeMunger> typeMungers, List<ConcreteTypeMunger> lateTypeMungers, boolean inReweavableMode) { BcelClassWeaver classWeaver = new BcelClassWeaver(world, clazz, shadowMungers, typeMungers, lateTypeMungers); @@ -2665,6 +2668,11 @@ class BcelClassWeaver implements IClassWeaver { if (isOverweaving && mg.getName().startsWith(NameMangler.PREFIX)) { return false; } + if (mg.getName().startsWith(SWITCH_TABLE_SYNTHETIC_METHOD_PREFIX) + && Objects.equals(mg.getReturnType().getSignature(), "[I")) { + // this is a synthetic switch helper, should be skipped (since it's not 'declared') + return false; + } enclosingShadow = BcelShadow.makeMethodExecution(world, mg, !canMatchBodyShadows); } else if (effective.isWeaveBody()) { ResolvedMember rm = effective.getEffectiveSignature(); @@ -3259,6 +3267,12 @@ class BcelClassWeaver implements IClassWeaver { } } } + + if (methodName.startsWith(SWITCH_TABLE_SYNTHETIC_METHOD_PREFIX)) { + // we shouldn't process calls to synthetic methods (since they're not 'declared') + proceed = false; + } + if (proceed) { match(BcelShadow.makeMethodCall(world, mg, ih, enclosingShadow), shadowAccumulator); } |