diff --git a/makefile b/makefile index 51e6bfff00..eab488d091 100644 --- a/makefile +++ b/makefile @@ -336,6 +336,8 @@ $(test-dep): $(test-sources) @mkdir -p $(dir $(@)) $(javac) -d $(dir $(@)) -bootclasspath $(classpath-build) \ $(shell $(MAKE) -s --no-print-directory $(test-classes)) + $(javac) -source 1.2 -target 1.1 -XDjsrlimit=0 -d $(dir $(@)) \ + test/Subroutine.java @touch $(@) define compile-object diff --git a/test/Subroutine.java b/test/Subroutine.java new file mode 100644 index 0000000000..c3491e1405 --- /dev/null +++ b/test/Subroutine.java @@ -0,0 +1,35 @@ +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 + // + private static void test(boolean throw_) { + int x = 42; + int y = 99; + int a = 0; + try { + try { + int z = x + y; + if (throw_) throw new DummyException(); + Integer.valueOf(z).toString(); + } finally { + a = x + y; + } + expect(a == x + y); + } catch (DummyException ignored) { } + } + + public static void main(String[] args) { + test(false); + test(true); + } + + private static class DummyException extends RuntimeException { } +}