9
0
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:
XiaoMoMi
2025-03-27 02:57:37 +08:00
parent 57034934b5
commit 46d87688a1
9 changed files with 45 additions and 16 deletions

View File

@@ -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;
}
}
}

View File

@@ -7,8 +7,6 @@ public interface InjectedPalettedContainerHolder {
Object target();
void target(Object target);
CESection ceSection();
void ceSection(CESection section);