2008-11-12 17:07:30 +00:00
|
|
|
public class Subroutine {
|
|
|
|
private static void expect(boolean v) {
|
|
|
|
if (! v) throw new RuntimeException();
|
|
|
|
}
|
|
|
|
|
|
|
|
// This test is 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
|
|
|
|
//
|
2008-11-17 15:21:20 +00:00
|
|
|
private static void test(boolean throw_, boolean predicate) {
|
2008-11-12 17:07:30 +00:00
|
|
|
int x = 42;
|
|
|
|
int y = 99;
|
|
|
|
int a = 0;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
int z = x + y;
|
|
|
|
if (throw_) throw new DummyException();
|
2008-11-17 15:21:20 +00:00
|
|
|
if (predicate) {
|
|
|
|
return;
|
|
|
|
}
|
2008-11-12 17:07:30 +00:00
|
|
|
Integer.valueOf(z).toString();
|
|
|
|
} finally {
|
|
|
|
a = x + y;
|
2008-11-14 00:59:21 +00:00
|
|
|
System.gc();
|
2008-11-12 17:07:30 +00:00
|
|
|
}
|
|
|
|
expect(a == x + y);
|
2008-11-14 00:59:21 +00:00
|
|
|
} catch (DummyException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2008-11-12 17:07:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
2008-11-17 15:21:20 +00:00
|
|
|
test(false, false);
|
|
|
|
test(false, true);
|
|
|
|
test(true, false);
|
2008-11-12 17:07:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static class DummyException extends RuntimeException { }
|
|
|
|
}
|