org.aspectj/tests/bugs/SwitchInAround.java
jhugunin 13b319a40f Fix for Bugzilla #39479, #40109
based on patch contributed by Andy Clement

Generalizes the patch with a method org.aspectj.weaver.bcel.Utility.copyInstruction
that works-around the bug in Select.copy().  Changed all calls to
Instruction.copy() to use this new method, would be nice to add the
rule:
   	 * declare error:
   	 *     call(* Instruction.copy()) && within(org.aspectj.weaver)
   	 *       && !withincode(* Utility.copyInstruction(Instruction)):
   	 *     "use Utility.copyInstruction to work-around bug in Select.copy()";
2003-07-16 23:19:54 +00:00

27 lines
528 B
Java

import org.aspectj.testing.Tester;
public class SwitchInAround {
public static void main(String[] args) {
SwitchInAround o = new SwitchInAround();
Tester.checkEqual(o.doit(1), "1");
Tester.checkEqual(o.doit(2), "2");
Tester.checkEqual(o.doit(3), "default");
}
public String doit(int i) {
return "doit";
}
}
privileged aspect A {
String around(int index): args(index) && call(String doit(int)) {
switch(index) {
case 1:
return "1";
case 2:
return "2";
default:
return "default";
}
}
}