public static synchronized MethodHandle equal(Class<?> type) {
checkArgument(type != void.class);
Class<?> erased = type.isPrimitive() ? type : Object.class;
if (cache == null) {
cache = new MapMaker().concurrencyLevel(2).makeMap();
}
MethodHandle result = cache.get(erased);
if (result == null) {
try {
result = lookup().findStatic(MethodHandleHelpers.class, "eq", methodType(boolean.class, erased, erased));
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new AssertionError(); // these all exist
}
cache.put(erased, result);
}
return result.asType(methodType(boolean.class, type, type));
}
MethodHandleHelpers.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:SevenCommons
作者:
评论列表
文章目录