jrobin: Disable DeallocationHelper for Java 9

This commit is contained in:
zzz
2018-01-10 15:39:05 +00:00
parent 1c3fc2bbdb
commit cfbcd54ba9
4 changed files with 33 additions and 6 deletions

View File

@ -127,7 +127,21 @@ public class DeallocationHelper {
cleanerCleanMethod.invoke(cleaner);
success = true;
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
//} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
} catch (IllegalAccessException | RuntimeException | InvocationTargetException e) {
// Replaced with RuntimeException for OpenJDK 9b181
// throws a java.lang.reflect.InaccessibleObjectException extends RuntimeException which is only in Java 9
// WARNING: An illegal reflective access operation has occurred
// WARNING: Illegal reflective access by engine.misc.DeallocationHelper (file:/path/to/jrobin.jar) to field java.nio.DirectByteBuffer.att
// WARNING: Please consider reporting this to the maintainers of engine.misc.DeallocationHelper
// WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
// WARNING: All illegal access operations will be denied in a future release
// Thread terminated unexpectedly: Shutdown task net.i2p.router.web.StatSummarizer$Shutdown
// java.lang.reflect.InaccessibleObjectException: Unable to make public void jdk.internal.ref.Cleaner.clean() accessible: module java.base does not "exports jdk.internal.ref" to unnamed module @381353a0
// at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:337)
// at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:281)
// at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
// at java.base/java.lang.reflect.Method.setAccessible(Method.java:192)
logger.warn("The deallocation of a direct NIO buffer has failed", e);
} finally {
directByteBufferCleanerMethod.setAccessible(directByteBufferCleanerMethodWasAccessible);

View File

@ -23,6 +23,7 @@ import java.io.IOException;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import net.i2p.util.SystemVersion;
import engine.misc.DeallocationHelper;
@ -35,7 +36,8 @@ import engine.misc.DeallocationHelper;
public class RrdNioBackend extends RrdFileBackend {
private final SyncManager m_syncManager;
private MappedByteBuffer m_byteBuffer = null;
private static final DeallocationHelper _dHelper = new DeallocationHelper();
// Too many ominous warnings from Java 9
private static final DeallocationHelper _dHelper = SystemVersion.isJava9() ? null : new DeallocationHelper();
/**
* Creates RrdFileBackend object for the given file path, backed by
@ -105,7 +107,7 @@ public class RrdNioBackend extends RrdFileBackend {
if (!isReadOnly()) {
stopSchedule();
}
if (m_byteBuffer != null) {
if (_dHelper != null && m_byteBuffer != null) {
_dHelper.deallocate(m_byteBuffer);
m_byteBuffer = null;
}