Bugzilla Bug 71273 - RuntimeException thrown: Could not find instruction: org.apache.bcel.generic.B2I
Bugzilla Bug 67591 - invalid warning indicating no match when a match really occurs
--- /dev/null
+//
+// class NoByteToInt {
+//
+// static final byte DEFAULT_MODE = 0;
+// static final byte RECORDING = 2;
+//
+// static byte mode = DEFAULT_MODE;
+//
+// public static void main (String[] args) {
+// mode = RECORDING;
+// }
+//
+//}
+//
+// privileged aspect LoggingControl {
+//
+// /* ERROR */
+// pointcut startRecording1 (int newMode) :
+// set(byte NoByteToInt.mode) && args(newMode) && if(newMode != 5);
+//
+// after () returning : startRecording1 (*) {
+//
+// }
+//
+//// /* OK */
+//// pointcut startRecording2 (byte newMode) :
+//// set(byte NoByteToInt.mode) && args(newMode) && if(newMode ==
+////NoByteToInt.RECORDING);
+////
+//// after () returning : startRecording2 (*) {
+////
+//// }
+//
+// /* OK */
+// pointcut startRecording3 (int newMode) :
+// set(byte NoByteToInt.mode) && args(newMode);
+//
+// after (int newMode) returning : startRecording3 (newMode) {
+// if (newMode == NoByteToInt.RECORDING) {
+//
+// }
+// }
+//}
+//
+public class NoByteToInt {
+
+ static byte mode;
+
+ public static void main (String[] args) {
+ setByte();
+ setChar();
+ setShort();
+ }
+
+ public static void setByte() {
+ mode = 0;
+ mode = 2;
+ mode = 127;
+ }
+
+ static char c;
+
+ public static void setChar() {
+ c = 'A';
+ c = 'B';
+ c = 'C';
+ }
+
+ static short s;
+
+ public static void setShort() {
+ s = 1;
+ s = 32767;
+ }
+
+}
+
+ privileged aspect LoggingControl {
+
+ /* ERROR */
+ pointcut startRecording1 (int newMode) :
+ set(byte NoByteToInt.mode) && args(newMode) && if(newMode!=3);
+
+ after (int n) returning : startRecording1 (n) {
+ System.err.println("[b"+n+"]");
+ }
+
+ pointcut startRecording2 (int newMode) :
+ set(char NoByteToInt.c) && args(newMode) && if(newMode!=3);
+
+ after (int n) returning : startRecording2 (n) {
+ System.err.println("[c"+n+"]");
+ }
+
+ pointcut startRecording3 (int newMode) :
+ set(short NoByteToInt.s) && args(newMode) && if(newMode!=3);
+
+ after (int n) returning : startRecording3 (n) {
+ System.err.println("[s"+n+"]");
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+public class Main {
+
+ private static class Foo {
+ int x;
+ Foo(int x) { this.x = x; }
+ };
+
+ private static int foo(int x) { return x+1; }
+
+ public static void main (String args[])
+ { Main.foo(1);
+ new Foo(2);
+ }
+
+ }
+
+ aspect Aspect {
+ // calls to a private method
+ before () : call(* foo(..))
+ { System.out.println("Matches * foo(..)");
+ }
+
+ before () : call(int foo(int))
+ { System.out.println("Matches int foo(int)");
+ }
+
+ before () : call(private * foo(..))
+ { System.out.println("Matches private * foo(..)");
+ }
+
+ before () : call(* foo*(..))
+ { System.out.println("Matches * foo*(..)");
+ }
+
+ // calls to a constructor that is in a private inner class
+ before () : call(Main.Foo.new(..)) // <- warning from here
+ { System.out.println("Matches Main.Foo.new(..)");
+ }
+
+ before () : call(Main.Foo*.new(..))
+ { System.out.println("Matches Main.Foo*.new(..)");
+ }
+
+ }
\ No newline at end of file
public void test014() {
runTest("NPE, Incorrect XLint:unmatchedSuperTypeInCall warning");
}
-
+
+ public void test015_invalidXlint() { // keywords: "laurie hendren"
+ runTest("invalid warning indicating no match when a match really occurs");
+ }
+
+ public void test016_ByteConversionInstructions() {
+ runTest("RuntimeException thrown: Could not find instruction: org.apache.bcel.generic.B2I");
+ String output = getLastRunResult().getStdErr();
+ assertTrue("Expected to find [b2] in this output but didn't:"+output,output.indexOf("[b2]")!=-1);
+ assertTrue("Expected to find [b127] in this output but didn't:"+output,output.indexOf("[b127]")!=-1);
+ assertTrue("Expected to find [b0] in this output but didn't:"+output,output.indexOf("[b0]")!=-1);
+
+ assertTrue("Expected to find [c65] in this output but didn't:"+output,output.indexOf("[c65]")!=-1);
+ assertTrue("Expected to find [c66] in this output but didn't:"+output,output.indexOf("[c66]")!=-1);
+ assertTrue("Expected to find [c67] in this output but didn't:"+output,output.indexOf("[c67]")!=-1);
+
+ assertTrue("Expected to find [s1] in this output but didn't:"+output,output.indexOf("[s1]")!=-1);
+ assertTrue("Expected to find [s32767] in this output but didn't:"+output,output.indexOf("[s32767]")!=-1);
+ assertTrue("Expected to find [b0] in this output but didn't:"+output,output.indexOf("[b0]")!=-1);
+ }
}
<compile files="IncorrectXlintOnInterface.java">
</compile>
</ajc-test>
+
+ <ajc-test dir="bugs/typeVisibilityProblem" pr="67591"
+ title="invalid warning indicating no match when a match really occurs">
+ <compile files="Main.java">
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs" pr="71273"
+ title="RuntimeException thrown: Could not find instruction: org.apache.bcel.generic.B2I">
+ <compile files="NoByteToInt.java"/>
+ <run class="NoByteToInt"/>
+ </ajc-test>
+