mirror of
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-09-13 15:45:38 +02:00
13b319a40f
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()";
27 lines
528 B
Java
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";
|
|
}
|
|
}
|
|
} |