diff options
author | Anthony Hilyard <anthony.hilyard@gmail.com> | 2023-03-29 23:12:14 -0700 |
---|---|---|
committer | Anthony Hilyard <anthony.hilyard@gmail.com> | 2023-03-29 23:12:14 -0700 |
commit | 81ee44c7b9297e24cf7b3e8be3452d06d4d7a7ac (patch) | |
tree | ce0352c615677bd5b9bebfcdfbca1a72bd6ebc6d /src/main/java/com/anthonyhilyard/iceberg/util | |
parent | b0d1aa6d5076738965f1f0fd9df98c6cd5bf946f (diff) | |
download | Iceberg-81ee44c7b9297e24cf7b3e8be3452d06d4d7a7ac.tar.gz Iceberg-81ee44c7b9297e24cf7b3e8be3452d06d4d7a7ac.tar.bz2 Iceberg-81ee44c7b9297e24cf7b3e8be3452d06d4d7a7ac.zip |
Fixed several 3d item preview issues.
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/util')
-rw-r--r-- | src/main/java/com/anthonyhilyard/iceberg/util/UnsafeUtil.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/UnsafeUtil.java b/src/main/java/com/anthonyhilyard/iceberg/util/UnsafeUtil.java new file mode 100644 index 0000000..d8410ce --- /dev/null +++ b/src/main/java/com/anthonyhilyard/iceberg/util/UnsafeUtil.java @@ -0,0 +1,40 @@ +package com.anthonyhilyard.iceberg.util; + +import sun.misc.Unsafe; + +import java.lang.reflect.Field; + +public class UnsafeUtil +{ + private static final Unsafe UNSAFE; + + static + { + try + { + Field field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + + UNSAFE = (Unsafe) field.get(null); + } + catch (NoSuchFieldException | IllegalAccessException e) + { + throw new RuntimeException("Couldn't obtain reference to sun.misc.Unsafe", e); + } + } + + public static float readFloat(long address) + { + return UNSAFE.getFloat(address); + } + + public static int readInt(long address) + { + return UNSAFE.getInt(address); + } + + public static byte readByte(long address) + { + return UNSAFE.getByte(address); + } +}
\ No newline at end of file |