diff options
| -rw-r--r-- | compiler/optimizing/nodes.h | 3 | ||||
| -rw-r--r-- | test/412-new-array/src/Main.java | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 21ed3504f1..da1468ecdb 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -2307,6 +2307,9 @@ class HNewArray : public HExpression<1> { // Calls runtime so needs an environment. bool NeedsEnvironment() const OVERRIDE { return true; } + // May throw NegativeArraySizeException, OutOfMemoryError, etc. + bool CanThrow() const OVERRIDE { return true; } + bool CanBeNull() const OVERRIDE { return false; } QuickEntrypointEnum GetEntrypoint() const { return entrypoint_; } diff --git a/test/412-new-array/src/Main.java b/test/412-new-array/src/Main.java index 168420cf8c..e4669b8a96 100644 --- a/test/412-new-array/src/Main.java +++ b/test/412-new-array/src/Main.java @@ -26,6 +26,7 @@ public class Main extends TestCase { $opt$TestWithInitializations(); $opt$TestNegativeValueNewByteArray(); $opt$TestNegativeValueNewCharArray(); + testNegativeArraySize(); testSmaliFilledNewArray(); testSmaliFillArrayData(); testSmaliVerifyError(); @@ -129,6 +130,21 @@ public class Main extends TestCase { } } + static void testNegativeArraySize() { + int i = 0; + try { + $opt$TestNegativeArraySize(); + } catch (NegativeArraySizeException e) { + i = 1; + } + assertEquals(i, 1); + } + + static int[] $opt$TestNegativeArraySize() { + int[] array = new int[-1]; + return null; + } + public static void testSmaliFilledNewArray() throws Exception { Class<?> c = Class.forName("FilledNewArray"); |