mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
add Subroutine test to cover jsr and ret instructions
This commit is contained in:
parent
fae0ccfe96
commit
4dd1d1eec8
2
makefile
2
makefile
@ -336,6 +336,8 @@ $(test-dep): $(test-sources)
|
|||||||
@mkdir -p $(dir $(@))
|
@mkdir -p $(dir $(@))
|
||||||
$(javac) -d $(dir $(@)) -bootclasspath $(classpath-build) \
|
$(javac) -d $(dir $(@)) -bootclasspath $(classpath-build) \
|
||||||
$(shell $(MAKE) -s --no-print-directory $(test-classes))
|
$(shell $(MAKE) -s --no-print-directory $(test-classes))
|
||||||
|
$(javac) -source 1.2 -target 1.1 -XDjsrlimit=0 -d $(dir $(@)) \
|
||||||
|
test/Subroutine.java
|
||||||
@touch $(@)
|
@touch $(@)
|
||||||
|
|
||||||
define compile-object
|
define compile-object
|
||||||
|
35
test/Subroutine.java
Normal file
35
test/Subroutine.java
Normal file
@ -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 { }
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user