MethodHandleHelpers.java 文件源码

java
阅读 33 收藏 0 点赞 0 评论 0

项目:SevenCommons 作者:
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));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号