mirror of
https://github.com/corda/corda.git
synced 2025-01-28 07:04:12 +00:00
9bb3d6b972
git-subtree-dir: sgx-jvm/avian git-subtree-mainline: f978eab8d134c88f88ff67e49458a771c32351db git-subtree-split: 09e4fe60d01f4f4bfb6b2976973bb4913ef61edc
42 lines
851 B
Java
42 lines
851 B
Java
public class StackOverflow {
|
|
private static int add(int[] numbers, int offset, int length) {
|
|
if (length == 0) {
|
|
return 0;
|
|
} else {
|
|
return numbers[offset] + add(numbers, offset + 1, length - 1);
|
|
}
|
|
}
|
|
private static int add(int ... numbers) {
|
|
return add(numbers, 0, numbers.length);
|
|
}
|
|
|
|
private static int test1() {
|
|
add(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
|
return test1() + 1;
|
|
}
|
|
|
|
private static int test2() {
|
|
return test3() + 1;
|
|
}
|
|
|
|
private static int test3() {
|
|
return test2() + 1;
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
try {
|
|
test1();
|
|
throw new RuntimeException();
|
|
} catch (StackOverflowError e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
test2();
|
|
throw new RuntimeException();
|
|
} catch (StackOverflowError e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|