diff --git a/Core/src/main/java/fr/pandacube/lib/core/util/ReflectionUtil.java b/Core/src/main/java/fr/pandacube/lib/core/util/ReflectionUtil.java index 78868ef..63128ea 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/util/ReflectionUtil.java +++ b/Core/src/main/java/fr/pandacube/lib/core/util/ReflectionUtil.java @@ -22,16 +22,25 @@ import io.github.classgraph.ScanResult; import sun.misc.Unsafe; public class ReflectionUtil { + + private record MethodCacheKey(Class clazz, String methodName, List> parameters) { } + private static final Map methodCache; + + private record FieldCacheKey(Class clazz, String fieldName) { }; + private static final Map fieldCache; + private static final Unsafe sunMiscUnsafeInstance; static { + methodCache = new HashMap<>(); + fieldCache = new HashMap<>(); try { sunMiscUnsafeInstance = (Unsafe) field("theUnsafe") .inClass(Unsafe.class) .getStaticValue(); } catch (Exception e) { - throw new RuntimeException(e); + throw new RuntimeException("Cannot access to " + Unsafe.class + ".theUnsafe value.", e); } } @@ -40,12 +49,6 @@ public class ReflectionUtil { - private record MethodCacheKey(Class clazz, String methodName, List> parameters) { } - private static final Map methodCache = new HashMap<>(); - - private record FieldCacheKey(Class clazz, String fieldName) { }; - private static final Map fieldCache = new HashMap<>(); -