diff options
author | nea <nea@nea.moe> | 2023-11-01 18:50:11 +0100 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-11-01 18:50:11 +0100 |
commit | 297cb01f220a617dd08096467978b2fccbc27695 (patch) | |
tree | d467f358313ce3648063da41b66361a840fa7864 /src/main/java/moe/nea/modernjava/launch/util/ReflectionUtils.java | |
parent | d5253dc5c3ae7b2cc1fcb96780e43b929a449eb4 (diff) | |
download | ModernJavaLauncher-297cb01f220a617dd08096467978b2fccbc27695.tar.gz ModernJavaLauncher-297cb01f220a617dd08096467978b2fccbc27695.tar.bz2 ModernJavaLauncher-297cb01f220a617dd08096467978b2fccbc27695.zip |
Add documentation
Diffstat (limited to 'src/main/java/moe/nea/modernjava/launch/util/ReflectionUtils.java')
-rw-r--r-- | src/main/java/moe/nea/modernjava/launch/util/ReflectionUtils.java | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/main/java/moe/nea/modernjava/launch/util/ReflectionUtils.java b/src/main/java/moe/nea/modernjava/launch/util/ReflectionUtils.java deleted file mode 100644 index abc2364..0000000 --- a/src/main/java/moe/nea/modernjava/launch/util/ReflectionUtils.java +++ /dev/null @@ -1,33 +0,0 @@ -package moe.nea.modernjava.launch.util; - -import sun.misc.Unsafe; - -import java.lang.reflect.Field; - -public class ReflectionUtils { - 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(); - } - } - - public static void makeFieldWritable(Field f) { - String s = "Doing nothing. We will use unsafe to set the value instead, if possible"; - } - - 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); - } - } -} |