lz4 / lz4-java

LZ4 compression for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sun.misc.Unsafe deprecated and unavailable

kolmisra opened this issue · comments

While building the code with JDK 17 and --release as 8 , java compiler complains about the class
https://github.com/lz4/lz4-java/blob/master/src/java-unsafe/net/jpountz/util/UnsafeUtils.java

Is there any alternate or fix available?

Even the --release 9 and higher works with the warning.
The need here to stay with --release as 8.

Here is a sample repro.
import sun.misc.Unsafe;
public class test1 {
private Unsafe UNSAFE=null;
}

javac --release 8 test1.java
test1.java:1: error: package sun.misc does not exist
import sun.misc.Unsafe;
^
test1.java:3: error: cannot find symbol
private Unsafe UNSAFE=null;
^
symbol: class Unsafe
location: class test1
2 errors

javac --release 9 test1.java
test1.java:1: warning: Unsafe is internal proprietary API and may be removed in a future release
import sun.misc.Unsafe;
^
test1.java:3: warning: Unsafe is internal proprietary API and may be removed in a future release
private Unsafe UNSAFE=null;
^
2 warnings

for now i have a temp solution.
javac -source 8 -target 8 -bootclasspath \Openjdk8\jre\lib\rt.jar test1.java

If there is any new fix to solve the deprecated warning please update.