Consider live any array that is passed or returned from JSNI.

Arrays created directly in JSNI were allowed in some circumstances
as it is used in the SDK for convenience.

This patch makes live any array type that is returned from JSNI or
passes from JSNI to Java.

Arrays created in this way will mostly work. If arrays created this
way are explicitly cast or checked via instanceof an exception might
occur.

Change-Id: I5482165a1e504de97a54e5514ec5be90dc84e3ea
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java b/dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java
index 53ebb19..f436467 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/ControlFlowAnalyzer.java
@@ -534,17 +534,15 @@
         return true;
       }
 
-      if (!(type instanceof JArrayType)) {
-        return false;
-      }
-
       /*
        * Hackish: in our own JRE we sometimes create "not quite baked" arrays
        * in JavaScript for expediency.
        */
-      JArrayType arrayType = (JArrayType) type;
-      JType elementType = arrayType.getElementType();
-      return elementType instanceof JPrimitiveType || canBeInstantiatedInJavaScript(elementType);
+      if (type instanceof JArrayType) {
+        return true;
+      }
+
+      return false;
     }
 
     private JMethod getStringValueOfCharMethod() {
@@ -655,9 +653,8 @@
              * consistent between optimized Java and JS.
              */
             rescue(param);
-            // Strings, JSOs, and JsTypes can all be instantiatd in Javascript
-            if (param.getType() == program.getTypeJavaLangString() ||
-                program.typeOracle.canBeInstantiatedInJavascript(param.getType())) {
+            // Strings, Arrays, JSOs, and JsTypes can all be instantiatd in Javascript
+            if (canBeInstantiatedInJavaScript(param.getType())) {
               // Param can be read from external JS if this method is implemented in JS
               // this should really be done in rescueArgumentsIfParametersCanBeRead, but
               // there is no JMethodCall to process since it might be from external JS
@@ -719,7 +716,6 @@
            * We may be able to tighten this to check for @JsExport as well,
            * since if there is no @JsExport, the only way for JS code to get a
            * reference to the interface is by it being constructed in Java
-           * and passed via JSNI into JS, and in that mechanism, the
            * rescue would happen automatically.
            */
         JDeclaredType dtype = (JDeclaredType) type;