import com.intellij.openapi.util.SystemInfoRt;
import com.intellij.util.concurrency.AtomicFieldUpdater;
import org.jetbrains.annotations.NotNull;
-import sun.misc.Unsafe;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
if (SystemInfoRt.IS_AT_LEAST_JAVA9) {
// in Java 9+, the "official" dispose method is sun.misc.Unsafe#invokeCleaner
- Unsafe unsafe = AtomicFieldUpdater.getUnsafe();
+ Object unsafe = AtomicFieldUpdater.getUnsafe();
try {
MethodType type = MethodType.methodType(void.class, ByteBuffer.class);
- @SuppressWarnings("JavaLangInvokeHandleSignature") MethodHandle handle = MethodHandles.lookup().findVirtual(Unsafe.class, "invokeCleaner", type);
- handle.invokeExact(unsafe, buffer);
+ @SuppressWarnings("JavaLangInvokeHandleSignature") MethodHandle handle = MethodHandles.lookup().findVirtual(unsafe.getClass(), "invokeCleaner", type);
+ handle.invoke(unsafe, buffer);
return true;
}
catch (Throwable t) {