From ebb061ae3908e2befa006c832b693d094b402f56 Mon Sep 17 00:00:00 2001 From: Konstantin Shandurenko Date: Tue, 23 Feb 2021 18:45:24 +0300 Subject: [PATCH] Removed LambdaMetafactoryUtils --- .../server/utils/LambdaMetafactoryUtils.java | 40 ------------------- 1 file changed, 40 deletions(-) delete mode 100644 src/main/java/net/minestom/server/utils/LambdaMetafactoryUtils.java diff --git a/src/main/java/net/minestom/server/utils/LambdaMetafactoryUtils.java b/src/main/java/net/minestom/server/utils/LambdaMetafactoryUtils.java deleted file mode 100644 index e6a1d396b..000000000 --- a/src/main/java/net/minestom/server/utils/LambdaMetafactoryUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.minestom.server.utils; - -import java.lang.invoke.LambdaMetafactory; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.util.function.Function; -import java.util.function.Supplier; - -@SuppressWarnings("unchecked") -public class LambdaMetafactoryUtils { - - private final static MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); - - public static Supplier getEmptyConstructor(Class targetClass) - throws Throwable { - MethodHandle handle = LOOKUP.findConstructor(targetClass, MethodType.methodType(void.class)); - return (Supplier) LambdaMetafactory.metafactory( - LOOKUP, - "get", - MethodType.methodType(Supplier.class), - handle.type().generic(), - handle, - handle.type() - ).getTarget().invokeExact(); - } - - public static Function getSingleArgumentConstructor(Class targetClass, Class argumentClass) throws Throwable { - MethodHandle handle = LOOKUP.findConstructor(targetClass, MethodType.methodType(void.class, argumentClass)); - return (Function) LambdaMetafactory.metafactory( - LOOKUP, - "apply", - MethodType.methodType(Function.class), - handle.type().generic(), - handle, - handle.type() - ).getTarget().invokeExact(); - } - -}