# HG changeset patch # User Tom Rodriguez # Date 1404243434 25200 # Node ID 67500ef4d102161283af20b766263109f483563e # Parent d91fecb90fc08544b1f76c7674abeab38cb71b8f Check for negative array size in Array.newInstance diff -r d91fecb90fc0 -r 67500ef4d102 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java Tue Jul 01 12:36:51 2014 -0700 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java Tue Jul 01 12:37:14 2014 -0700 @@ -36,6 +36,9 @@ public static Object newInstance(Class componentType, int length) throws NegativeArraySizeException { // The error cases must be handled here since DynamicNewArrayNode can only deoptimize the // caller in response to exceptions. + if (length < 0) { + throw new NegativeArraySizeException(); + } if (componentType == void.class) { throw new IllegalArgumentException(); }