You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
val internalOffsetMethod = internalUnsafe.javaClass.getDeclaredMethod("objectFieldOffset", Field::class.java)
21
-
val bool = unsafe.getBoolean(internalOffsetMethod, 12)
22
-
unsafe.putBoolean(internalOffsetMethod, 12, true) // Make it accessible
22
+
val newHeader =Runtime.version().version().first() >=24&&ManagementFactory.getRuntimeMXBean().inputArguments.any { it =="-XX:+UseCompactObjectHeaders" }
23
+
val accessibleOffset =if (newHeader) 8Lelse12L
24
+
val bool = unsafe.getBoolean(internalOffsetMethod, accessibleOffset)
25
+
unsafe.putBoolean(internalOffsetMethod, accessibleOffset, true) // Make it accessible
23
26
internalOffset = internalOffsetMethod.handle(pType =Any::class.java) // This checks for accessible when we get it
24
-
unsafe.putBoolean(internalOffsetMethod, 12, bool) // Set accessible back, we no longer need the hack
27
+
unsafe.putBoolean(internalOffsetMethod, accessibleOffset, bool) // Set accessible back, we no longer need the hack
0 commit comments