Move JSNI reference out of Arrays.java

The jsni conversion tool used to make the JRE work
for j2cl chokes on JSNI references. Arrays has "valid"
JSNI that needs to be converted as well as this reference.
By moving it into a seperate file we can still use the
conversion tool.

Change-Id: I65bf7f4b215d1b976da2e63a04a708545fb3a910
diff --git a/dev/core/super/javaemul/internal/LongCompareHolder.java b/dev/core/super/javaemul/internal/LongCompareHolder.java
new file mode 100644
index 0000000..5a75c7c
--- /dev/null
+++ b/dev/core/super/javaemul/internal/LongCompareHolder.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package javaemul.internal;
+
+/**
+ * A helper class for long comparison.
+ */
+public class LongCompareHolder {
+  // TODO(dankurka): replace this with @JsFunction once its available in GWT.
+  public static native Object getLongComparator() /*-{
+    return @com.google.gwt.lang.LongLib::compare(*);
+  }-*/;
+}
+
diff --git a/user/super/com/google/gwt/emul/java/util/Arrays.java b/user/super/com/google/gwt/emul/java/util/Arrays.java
index fb98202..c60eda7 100644
--- a/user/super/com/google/gwt/emul/java/util/Arrays.java
+++ b/user/super/com/google/gwt/emul/java/util/Arrays.java
@@ -27,6 +27,7 @@
 import java.io.Serializable;
 
 import javaemul.internal.ArrayHelper;
+import javaemul.internal.LongCompareHolder;
 
 /**
  * Utility methods related to native arrays. <a
@@ -1010,7 +1011,7 @@
   }
 
   public static void sort(long[] array) {
-    nativeLongSort(array);
+    nativeLongSort(array, LongCompareHolder.getLongComparator());
   }
 
   public static void sort(long[] array, int fromIndex, int toIndex) {
@@ -1356,8 +1357,8 @@
   /**
    * Sort an entire array of number primitives.
    */
-  private static native void nativeLongSort(Object array) /*-{
-    array.sort(@com.google.gwt.lang.LongLib::compare(*));
+  private static native void nativeLongSort(Object array, Object compareFunction) /*-{
+    array.sort(compareFunction);
   }-*/;
 
   /**
@@ -1365,7 +1366,7 @@
    */
   private static void nativeLongSort(Object array, int fromIndex, int toIndex) {
     Object temp = ArrayHelper.unsafeClone(array, fromIndex, toIndex);
-    nativeLongSort(temp);
+    nativeLongSort(temp, LongCompareHolder.getLongComparator());
     ArrayHelper.copy(temp, 0, array, fromIndex, toIndex - fromIndex);
   }