diff options
author | Linnea Gräf <nea@nea.moe> | 2024-06-20 02:48:38 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-06-20 02:48:38 +0200 |
commit | 5593488744dc5aa994b5ab2806ed56d7bc627368 (patch) | |
tree | 9d8701474adbd0ce3d51c3f2b92e7ed5724b02a7 /src/main/java/moe/nea/modernjava/launch/util/ObjectHolderRefCompanion.java | |
parent | cb08a83e7a0f82f2459da7cb93b8c327b29d9838 (diff) | |
download | ModernJavaLauncher-master.tar.gz ModernJavaLauncher-master.tar.bz2 ModernJavaLauncher-master.zip |
Diffstat (limited to 'src/main/java/moe/nea/modernjava/launch/util/ObjectHolderRefCompanion.java')
-rw-r--r-- | src/main/java/moe/nea/modernjava/launch/util/ObjectHolderRefCompanion.java | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/main/java/moe/nea/modernjava/launch/util/ObjectHolderRefCompanion.java b/src/main/java/moe/nea/modernjava/launch/util/ObjectHolderRefCompanion.java index 15f9450..3b31b4e 100644 --- a/src/main/java/moe/nea/modernjava/launch/util/ObjectHolderRefCompanion.java +++ b/src/main/java/moe/nea/modernjava/launch/util/ObjectHolderRefCompanion.java @@ -1,44 +1,44 @@ package moe.nea.modernjava.launch.util; -import moe.nea.modernjava.launch.transform.TransObjectHolderRef; +import moe.nea.modernjava.launch.transform.PatchObjectHolderRef; import sun.misc.Unsafe; import java.lang.reflect.Field; /** - * A companion to my transformations from {@link TransObjectHolderRef} to avoid + * A companion to my transformations from {@link PatchObjectHolderRef} to avoid * having to write all of this out in bytecode. */ public class ObjectHolderRefCompanion { - private static Unsafe unsafe; + private static Unsafe unsafe; - static { - try { - final Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe"); - unsafeField.setAccessible(true); - unsafe = (Unsafe) unsafeField.get(null); - } catch (Exception ex) { - ex.printStackTrace(); - } - } + static { + try { + final Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe"); + unsafeField.setAccessible(true); + unsafe = (Unsafe) unsafeField.get(null); + } catch (Exception ex) { + ex.printStackTrace(); + } + } - /** - * A noop to have a jump target for the reflection factories. - */ - public static void makeFieldWritable(Field f) { - String s = "Doing nothing. We will use unsafe to set the value instead, if possible"; - } + /** + * A noop to have a jump target for the reflection factories. + */ + public static void makeFieldWritable(Field f) { + String s = "Doing nothing. We will use unsafe to set the value instead, if possible"; + } - /** - * Write a value to a static final field. - */ - public static void doFieldWrite(Field field, Object object) throws IllegalAccessException { - if (unsafe == null) { - field.set(null, object); - } else { - Object o = unsafe.staticFieldBase(field); - long l = unsafe.staticFieldOffset(field); - unsafe.putObject(o, l, object); - } - } + /** + * Write a value to a static final field. + */ + public static void doFieldWrite(Field field, Object object) throws IllegalAccessException { + if (unsafe == null) { + field.set(null, object); + } else { + Object o = unsafe.staticFieldBase(field); + long l = unsafe.staticFieldOffset(field); + unsafe.putObject(o, l, object); + } + } } |