src/jdk/nashorn/internal/objects/NativeArray.java

Print this page

        

@@ -74,11 +74,11 @@
     private static final MethodHandle MAP_CALLBACK_INVOKER     = createIteratorCallbackInvoker(Object.class);
     private static final MethodHandle FILTER_CALLBACK_INVOKER  = createIteratorCallbackInvoker(boolean.class);
 
     private static final MethodHandle REDUCE_CALLBACK_INVOKER = Bootstrap.createDynamicInvoker("dyn:call", Object.class,
             Object.class, Undefined.class, Object.class, Object.class, int.class, Object.class);
-    private static final MethodHandle CALL_CMP                = Bootstrap.createDynamicInvoker("dyn:call", int.class,
+    private static final MethodHandle CALL_CMP                = Bootstrap.createDynamicInvoker("dyn:call", double.class,
             ScriptFunction.class, Object.class, Object.class, Object.class);
 
     private static final InvokeByName TO_LOCALE_STRING = new InvokeByName("toLocaleString", ScriptObject.class, String.class);
 
 

@@ -821,11 +821,12 @@
                     return -1;
                 }
 
                 if (cmp != null) {
                     try {
-                        return (int)CALL_CMP.invokeExact(cmp, cmpThis, x, y);
+                        double res = (double)CALL_CMP.invokeExact(cmp, cmpThis, x, y);
+                        return (int)Math.signum(res);
                     } catch (final RuntimeException | Error e) {
                         throw e;
                     } catch (final Throwable t) {
                         throw new RuntimeException(t);
                     }