Mercurial > hg > truffle
comparison graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java @ 16382:67500ef4d102
Check for negative array size in Array.newInstance
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Tue, 01 Jul 2014 12:37:14 -0700 |
parents | cc76575f485c |
children | 14e703edb2ab |
comparison
equal
deleted
inserted
replaced
16381:d91fecb90fc0 | 16382:67500ef4d102 |
---|---|
34 | 34 |
35 @MethodSubstitution | 35 @MethodSubstitution |
36 public static Object newInstance(Class<?> componentType, int length) throws NegativeArraySizeException { | 36 public static Object newInstance(Class<?> componentType, int length) throws NegativeArraySizeException { |
37 // The error cases must be handled here since DynamicNewArrayNode can only deoptimize the | 37 // The error cases must be handled here since DynamicNewArrayNode can only deoptimize the |
38 // caller in response to exceptions. | 38 // caller in response to exceptions. |
39 if (length < 0) { | |
40 throw new NegativeArraySizeException(); | |
41 } | |
39 if (componentType == void.class) { | 42 if (componentType == void.class) { |
40 throw new IllegalArgumentException(); | 43 throw new IllegalArgumentException(); |
41 } | 44 } |
42 return DynamicNewArrayNode.newArray(GuardingPiNode.guardingNonNull(componentType), length); | 45 return DynamicNewArrayNode.newArray(GuardingPiNode.guardingNonNull(componentType), length); |
43 } | 46 } |