diff --git a/test/Subroutine.java b/test/Subroutine.java index 3ad78b00b8..a976c53dfd 100644 --- a/test/Subroutine.java +++ b/test/Subroutine.java @@ -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 { }