Tried to add 1.20.4 support
This commit is contained in:
parent
3fc8db17ce
commit
3975898e59
|
@ -12,18 +12,14 @@ public final class FieldHelper {
|
||||||
public static void setFieldUsingUnsafe(final Field field, final Object object, final Object newValue) {
|
public static void setFieldUsingUnsafe(final Field field, final Object object, final Object newValue) {
|
||||||
try {
|
try {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
System.out.println("field on accessible");
|
|
||||||
int fieldModifiersMask = field.getModifiers();
|
int fieldModifiersMask = field.getModifiers();
|
||||||
boolean isFinalModifierPresent = (fieldModifiersMask & Modifier.FINAL) == Modifier.FINAL;
|
boolean isFinalModifierPresent = (fieldModifiersMask & Modifier.FINAL) == Modifier.FINAL;
|
||||||
if (isFinalModifierPresent) {
|
if (isFinalModifierPresent) {
|
||||||
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
|
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
|
||||||
try {
|
try {
|
||||||
sun.misc.Unsafe unsafe = getUnsafe();
|
sun.misc.Unsafe unsafe = getUnsafe();
|
||||||
System.out.println("unsafe on käes");
|
|
||||||
long offset = unsafe.objectFieldOffset(field);
|
long offset = unsafe.objectFieldOffset(field);
|
||||||
System.out.println("offset mida iganes");
|
|
||||||
setFieldUsingUnsafe(object, field.getType(), offset, newValue, unsafe);
|
setFieldUsingUnsafe(object, field.getType(), offset, newValue, unsafe);
|
||||||
System.out.println("see teine setfieldusingunsafe sai hakkama");
|
|
||||||
return null;
|
return null;
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
throw new RuntimeException(t);
|
throw new RuntimeException(t);
|
||||||
|
|
Loading…
Reference in New Issue