diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/061-out-of-memory/expected.txt | 1 | ||||
| -rw-r--r-- | test/061-out-of-memory/src/Main.java | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/test/061-out-of-memory/expected.txt b/test/061-out-of-memory/expected.txt index ca876299f5..c31980cad7 100644 --- a/test/061-out-of-memory/expected.txt +++ b/test/061-out-of-memory/expected.txt @@ -4,4 +4,5 @@ testOomeLarge beginning testOomeLarge succeeded testOomeSmall beginning testOomeSmall succeeded +Got expected toCharArray OOM tests succeeded diff --git a/test/061-out-of-memory/src/Main.java b/test/061-out-of-memory/src/Main.java index c812c81114..52373d3c5f 100644 --- a/test/061-out-of-memory/src/Main.java +++ b/test/061-out-of-memory/src/Main.java @@ -26,6 +26,7 @@ public class Main { testHugeArray(); testOomeLarge(); testOomeSmall(); + testOomeToCharArray(); System.out.println("tests succeeded"); } @@ -106,4 +107,22 @@ public class Main { } System.out.println("testOomeSmall succeeded"); } + + private static void testOomeToCharArray() { + Object[] o = new Object[1000000]; + String test = "test"; + int i = 0; + try { + for (; i < o.length; ++i) o[i] = new char[1000000]; + } catch (OutOfMemoryError oom) {} + try { + for (; i < o.length; ++i) o[i] = new Object(); + } catch (OutOfMemoryError oom) {} + try { + test.toCharArray(); + } catch (OutOfMemoryError oom) { + o = null; + System.out.println("Got expected toCharArray OOM"); + } + } } |