Java Code Examples for java.lang.invoke.ConstantCallSite#dynamicInvoker()

The following examples show how to use java.lang.invoke.ConstantCallSite#dynamicInvoker() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Lng.java    From boon with Apache License 2.0 6 votes vote down vote up
/**
 * Reduce by functional support for int arrays.
 * @param array array of items to reduce by
 * @param object object that contains the reduce by function
 * @param <T> the type of object
 * @return the final reduction
 */
public  static <T> long reduceBy( final long[] array, T object ) {
    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, object );
    }


    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object);
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            long sum = 0;
            for ( long v : array ) {
                sum = (long) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, object);
    }

}
 
Example 2
Source File: Flt.java    From boon with Apache License 2.0 6 votes vote down vote up
/**
 * Reduce by functional support for int arrays.
 * @param array array of items to reduce by
 * @param object object that contains the reduce by function
 * @param <T> the type of object
 * @return the final reduction
 */
public  static <T> double reduceBy( final float[] array, T object ) {
    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, object );
    }


    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object);
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            double sum = 0;
            for ( float v : array ) {
                sum = (double) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, object);
    }

}
 
Example 3
Source File: Dbl.java    From boon with Apache License 2.0 6 votes vote down vote up
/**
 * Reduce by functional support for int arrays.
 * @param array array of items to reduce by
 * @param object object that contains the reduce by function
 * @param <T> the type of object
 * @return the final reduction
 */
public  static <T> double reduceBy( final double[] array, T object ) {
    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, object );
    }


    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object);
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            double sum = 0;
            for ( double v : array ) {
                sum = (double) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, object);
    }

}
 
Example 4
Source File: Int.java    From boon with Apache License 2.0 6 votes vote down vote up
/**
 * Reduce by functional support for int arrays.
 * @param array array of items to reduce by
 * @param object object that contains the reduce by function
 * @param <T> the type of object
 * @return the final reduction
 */
public  static <T> long reduceBy( final int[] array, T object ) {
    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, object );
    }


    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object);
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            long sum = 0;
            for ( int v : array ) {
                sum = (long) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, object);
    }

}
 
Example 5
Source File: Dbl.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce By
 * @param array array of items to reduce by
 * @param length where to end in the array
 * @param object function
 * @return reduction
 */
public static double reduceBy( final double[] array, int start, int length,
                               Object object ) {


    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, object );
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object );
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            double sum = 0;
            for (int index=start; index < length; index++) {
                double v = array[index];
                sum = (double) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, object );
    }

}
 
Example 6
Source File: Dbl.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce By
 * @param array array of items to reduce by
 * @param length where to end in the array
 * @param function function
 * @param function functionName
 * @return reduction
 */
public static double reduceBy( final double[] array,  int length,
                               Object function, String functionName ) {


    if (function.getClass().isAnonymousClass()) {
        return reduceByR(array, length, function, functionName );
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(function, functionName );
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            double sum = 0;
            for (int index=0; index < length; index++) {
                double v = array[index];
                sum = (double) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, length, function, functionName );
    }


}
 
Example 7
Source File: Dbl.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce By
 * @param array array of items to reduce by
 * @param length where to end in the array
 * @param object function
 * @return reduction
 */
public static double reduceBy( final double[] array,  int length,
                               Object object ) {


    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, length, object );
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object );
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            double sum = 0;
            for (int index=0; index < length; index++) {
                double v = array[index];
                sum = (double) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, length, object );
    }


}
 
Example 8
Source File: Dbl.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce by functional support for int arrays.
 * @param array array of items to reduce by
 * @param object object that contains the reduce by function
 * @param <T> the type of object
 * @return the final reduction
 */
public static <T> double reduceBy( final double[] array, T object, String methodName ) {

    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, object, methodName);
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object, methodName);
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            double sum = 0;
            for ( double v : array ) {
                sum = (double) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, object, methodName);
    }


}
 
Example 9
Source File: Int.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce By
 * @param array array of items to reduce by
 * @param length where to end in the array
 * @param object function
 * @return reduction
 */
public static long reduceBy( final int[] array, int start, int length,
                             Object object ) {


    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, object );
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object );
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            long sum = 0;
            for (int index=start; index < length; index++) {
                int v = array[index];
                sum = (long) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, object );
    }

}
 
Example 10
Source File: Int.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce By
 * @param array array of items to reduce by
 * @param length where to end in the array
 * @param function function
 * @param function functionName
 * @return reduction
 */
public static long reduceBy( final int[] array,  int length,
                             Object function, String functionName ) {


    if (function.getClass().isAnonymousClass()) {
        return reduceByR(array, length, function, functionName );
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(function, functionName );
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            long sum = 0;
            for (int index=0; index < length; index++) {
                int v = array[index];
                sum = (long) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, length, function, functionName );
    }


}
 
Example 11
Source File: Int.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce By
 * @param array array of items to reduce by
 * @param length where to end in the array
 * @param object function
 * @return reduction
 */
public static long reduceBy( final int[] array,  int length,
                             Object object ) {


    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, length, object );
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object );
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            long sum = 0;
            for (int index=0; index < length; index++) {
                int v = array[index];
                sum = (long) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, length, object );
    }


}
 
Example 12
Source File: Int.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce by functional support for int arrays.
 * @param array array of items to reduce by
 * @param object object that contains the reduce by function
 * @param <T> the type of object
 * @return the final reduction
 */
public static <T> long reduceBy( final int[] array, T object, String methodName ) {

    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, object, methodName);
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object, methodName);
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            long sum = 0;
            for ( int v : array ) {
                    sum = (long) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, object, methodName);
    }


}
 
Example 13
Source File: Flt.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce By
 * @param array array of items to reduce by
 * @param length where to end in the array
 * @param object function
 * @return reduction
 */
public static double reduceBy( final float[] array, int start, int length,
                             Object object ) {


    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, object );
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object );
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            double sum = 0;
            for (int index=start; index < length; index++) {
                float v = array[index];
                sum = (double) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, object );
    }

}
 
Example 14
Source File: Flt.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce By
 * @param array array of items to reduce by
 * @param length where to end in the array
 * @param function function
 * @param function functionName
 * @return reduction
 */
public static double reduceBy( final float[] array,  int length,
                             Object function, String functionName ) {


    if (function.getClass().isAnonymousClass()) {
        return reduceByR(array, length, function, functionName );
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(function, functionName );
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            double sum = 0;
            for (int index=0; index < length; index++) {
                float v = array[index];
                sum = (double) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, length, function, functionName );
    }


}
 
Example 15
Source File: Flt.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce By
 * @param array array of items to reduce by
 * @param length where to end in the array
 * @param object function
 * @return reduction
 */
public static double reduceBy( final float[] array,  int length,
                             Object object ) {


    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, length, object );
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object );
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            double sum = 0;
            for (int index=0; index < length; index++) {
                float v = array[index];
                sum = (double) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, length, object );
    }


}
 
Example 16
Source File: Flt.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce by functional support for int arrays.
 * @param array array of items to reduce by
 * @param object object that contains the reduce by function
 * @param <T> the type of object
 * @return the final reduction
 */
public static <T> double reduceBy( final float[] array, T object, String methodName ) {

    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, object, methodName);
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object, methodName);
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            double sum = 0;
            for ( float v : array ) {
                sum = (double) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, object, methodName);
    }


}
 
Example 17
Source File: Lng.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce By
 * @param array array of items to reduce by
 * @param length where to end in the array
 * @param object function
 * @return reduction
 */
public static long reduceBy( final long[] array, int start, int length,
                             Object object ) {


    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, object );
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object );
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            long sum = 0;
            for (int index=start; index < length; index++) {
                long v = array[index];
                sum = (long) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, object );
    }

}
 
Example 18
Source File: Lng.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce By
 * @param array array of items to reduce by
 * @param length where to end in the array
 * @param function function
 * @param function functionName
 * @return reduction
 */
public static long reduceBy( final long[] array,  int length,
                             Object function, String functionName ) {


    if (function.getClass().isAnonymousClass()) {
        return reduceByR(array, length, function, functionName );
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(function, functionName );
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            long sum = 0;
            for (int index=0; index < length; index++) {
                long v = array[index];
                sum = (long) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, length, function, functionName );
    }


}
 
Example 19
Source File: Lng.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce By
 * @param array array of items to reduce by
 * @param length where to end in the array
 * @param object function
 * @return reduction
 */
public static long reduceBy( final long[] array,  int length,
                             Object object ) {


    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, length, object );
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object );
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            long sum = 0;
            for (int index=0; index < length; index++) {
                long v = array[index];
                sum = (long) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, length, object );
    }


}
 
Example 20
Source File: Lng.java    From boon with Apache License 2.0 5 votes vote down vote up
/**
 * Reduce by functional support for int arrays.
 * @param array array of items to reduce by
 * @param object object that contains the reduce by function
 * @param <T> the type of object
 * @return the final reduction
 */
public static <T> long reduceBy( final long[] array, T object, String methodName ) {

    if (object.getClass().isAnonymousClass()) {
        return reduceByR(array, object, methodName);
    }

    try {
        ConstantCallSite callSite = Invoker.invokeReducerLongIntReturnLongMethodHandle(object, methodName);
        MethodHandle methodHandle = callSite.dynamicInvoker();
        try {

            long sum = 0;
            for ( long v : array ) {
                sum = (long) methodHandle.invokeExact( sum, v );

            }
            return sum;
        } catch (Throwable throwable) {
            return handle(Long.class, throwable, "Unable to perform reduceBy");
        }
    } catch (Exception ex) {
        return reduceByR(array, object, methodName);
    }


}