changeset 16125:cc76575f485c

handle error case in Array.newInstance
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 17 Jun 2014 12:47:45 -0700
parents 4a9d5d60fa58
children dbd32c5942e8
files graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java	Tue Jun 17 12:47:21 2014 -0700
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java	Tue Jun 17 12:47:45 2014 -0700
@@ -34,6 +34,11 @@
 
     @MethodSubstitution
     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 (componentType == void.class) {
+            throw new IllegalArgumentException();
+        }
         return DynamicNewArrayNode.newArray(GuardingPiNode.guardingNonNull(componentType), length);
     }