mirror da
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-08-26 17:58:43 +02:00
![jhugunin](/assets/img/avatar_default.png)
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 righe
528 B
Java
27 righe
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";
|
|
}
|
|
}
|
|
} |