add new test to Subroutine to trigger latent bug compiling multiple jsr instructions to the same address

This commit is contained in:
Joel Dice 2009-06-10 18:11:27 -06:00
parent 70eedcdf97
commit b35a5a6db6

View File

@ -3,13 +3,14 @@ public class Subroutine {
if (! v) throw new RuntimeException();
}
// This test is intended to cover the jsr and ret instructions.
// These tests are intended to cover the jsr and ret instructions.
// However, recent Sun javac versions avoid generating these
// instructions by default, so we must compile this class using
// -source 1.2 -target 1.1 -XDjsrlimit=0.
//
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4381996
//
private static void test(boolean throw_, boolean predicate) {
int x = 42;
int y = 99;
@ -32,10 +33,39 @@ public class Subroutine {
}
}
private static Object test2(int path) {
try {
try {
switch (path) {
case 1:
return new Object();
case 2: {
int a = 42;
return Integer.valueOf(a);
}
case 3:
throw new DummyException();
}
} finally {
System.gc();
}
return null;
} catch (DummyException e) {
e.printStackTrace();
return null;
}
}
public static void main(String[] args) {
test(false, false);
test(false, true);
test(true, false);
test2(1);
test2(2);
test2(3);
}
private static class DummyException extends RuntimeException { }