mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-06 15:52:03 +00:00
optimizzze
This commit is contained in:
@@ -5,6 +5,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.VarHandle;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -467,4 +468,22 @@ public class ReflectionUtils {
|
||||
return LOOKUP.unreflect(method);
|
||||
}
|
||||
}
|
||||
|
||||
public static VarHandle findVarHandle(Class<?> clazz, String name, Class<?> type) {
|
||||
try {
|
||||
return MethodHandles.privateLookupIn(clazz, LOOKUP)
|
||||
.findVarHandle(clazz, name, type);
|
||||
} catch (NoSuchFieldException | SecurityException | IllegalAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static VarHandle findVarHandle(Field field) {
|
||||
try {
|
||||
return MethodHandles.privateLookupIn(field.getDeclaringClass(), LOOKUP)
|
||||
.findVarHandle(field.getDeclaringClass(), field.getName(), field.getType());
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ public interface InjectedPalettedContainerHolder {
|
||||
|
||||
Object target();
|
||||
|
||||
void target(Object target);
|
||||
|
||||
CESection ceSection();
|
||||
|
||||
void ceSection(CESection section);
|
||||
|
||||
Reference in New Issue
Block a user