本文整理汇总了Java中java.lang.invoke.ConstantCallSite.dynamicInvoker方法的典型用法代码示例。如果您正苦于以下问题:Java ConstantCallSite.dynamicInvoker方法的具体用法?Java ConstantCallSite.dynamicInvoker怎么用?Java ConstantCallSite.dynamicInvoker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.invoke.ConstantCallSite
的用法示例。
在下文中一共展示了ConstantCallSite.dynamicInvoker方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reduceBy
import java.lang.invoke.ConstantCallSite; //导入方法依赖的package包/类
/**
* 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);
}
}
示例2: reduceBy
import java.lang.invoke.ConstantCallSite; //导入方法依赖的package包/类
/**
* 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 Exceptions.handle(Long.class, throwable, "Unable to perform reduceBy");
}
} catch (Exception ex) {
return reduceByR(array, object);
}
}
示例3: reduceBy
import java.lang.invoke.ConstantCallSite; //导入方法依赖的package包/类
/**
* 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);
}
}
示例4: reduceBy
import java.lang.invoke.ConstantCallSite; //导入方法依赖的package包/类
/**
* 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 Exceptions.handle(Long.class, throwable, "Unable to perform reduceBy");
}
} catch (Exception ex) {
return reduceByR(array, object);
}
}