9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-30 20:39:10 +00:00

perf(bukkit): 反射性能优化

This commit is contained in:
jhqwqmc
2025-06-17 07:57:50 +08:00
parent b9dc2976ae
commit f3c8d9c8c5
4 changed files with 23 additions and 4 deletions

View File

@@ -512,6 +512,15 @@ public class ReflectionUtils {
}
}
public static MethodHandle unreflectConstructor(Constructor<?> constructor) throws IllegalAccessException {
try {
return LOOKUP.unreflectConstructor(constructor);
} catch (IllegalAccessException e) {
constructor.setAccessible(true);
return LOOKUP.unreflectConstructor(constructor);
}
}
public static VarHandle findVarHandle(Class<?> clazz, String name, Class<?> type) {
try {
return MethodHandles.privateLookupIn(clazz, LOOKUP)