This commit is contained in:
Andrea Cavalli 2021-09-03 02:22:55 +02:00
parent a8028024c8
commit 47de651c94
5 changed files with 9 additions and 11 deletions

View File

@ -364,8 +364,8 @@ public class LLUtils {
); );
} }
if (!MemorySegmentUtils.isSupported()) { if (!MemorySegmentUtils.isSupported()) {
throw new UnsupportedOperationException("Please enable Foreign Memory Access API support or disable" throw new UnsupportedOperationException("Foreign Memory Access API support is disabled."
+ " netty direct buffers"); + " Please set \"--enable-preview --add-modules jdk.incubator.foreign -Dforeign.restricted=permit\"");
} }
assert buffer.isAccessible(); assert buffer.isAccessible();
long nativeAddress; long nativeAddress;

View File

@ -98,8 +98,8 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
); );
} }
if (!MemorySegmentUtils.isSupported()) { if (!MemorySegmentUtils.isSupported()) {
throw new UnsupportedOperationException("Please enable Foreign Memory Access API support or disable" throw new UnsupportedOperationException("Foreign Memory Access API support is disabled."
+ " netty direct buffers"); + " Please set \"--enable-preview --add-modules jdk.incubator.foreign -Dforeign.restricted=permit\"");
} }
} }

View File

@ -75,12 +75,14 @@ public class MemorySegmentUtils {
if (PlatformDependent.hasDirectBufferNoCleanerConstructor()) { if (PlatformDependent.hasDirectBufferNoCleanerConstructor()) {
return PlatformDependent.directBuffer(address, (int) size); return PlatformDependent.directBuffer(address, (int) size);
} }
throw new UnsupportedOperationException("Foreign Memory Access API is not enabled!"); throw new UnsupportedOperationException("Foreign Memory Access API is disabled!"
+ " Please set \"--enable-preview --add-modules jdk.incubator.foreign -Dforeign.restricted=permit\"");
} }
var memorySegment = AS_SLICE.invoke(NATIVE, address, size); var memorySegment = AS_SLICE.invoke(NATIVE, address, size);
return (ByteBuffer) AS_BYTE_BUFFER.invoke(memorySegment); return (ByteBuffer) AS_BYTE_BUFFER.invoke(memorySegment);
} catch (Throwable e) { } catch (Throwable e) {
throw new UnsupportedOperationException("Foreign Memory Access API is not enabled!", e); throw new UnsupportedOperationException("Foreign Memory Access API is disabled!"
+ " Please set \"--enable-preview --add-modules jdk.incubator.foreign -Dforeign.restricted=permit\"", e);
} }
} }

View File

@ -22,25 +22,21 @@ public class JMXPooledNettyMonitoring extends JMXNettyMonitoring implements JMXN
//noinspection JavaReflectionMemberAccess //noinspection JavaReflectionMemberAccess
numThreadLocalCaches = metric.getClass().getDeclaredField("numThreadLocalCaches"); numThreadLocalCaches = metric.getClass().getDeclaredField("numThreadLocalCaches");
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
e.printStackTrace();
} }
try { try {
//noinspection JavaReflectionMemberAccess //noinspection JavaReflectionMemberAccess
smallCacheSize = metric.getClass().getDeclaredField("smallCacheSize"); smallCacheSize = metric.getClass().getDeclaredField("smallCacheSize");
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
e.printStackTrace();
} }
try { try {
//noinspection JavaReflectionMemberAccess //noinspection JavaReflectionMemberAccess
normalCacheSize = metric.getClass().getDeclaredField("normalCacheSize"); normalCacheSize = metric.getClass().getDeclaredField("normalCacheSize");
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
e.printStackTrace();
} }
try { try {
//noinspection JavaReflectionMemberAccess //noinspection JavaReflectionMemberAccess
chunkSize = metric.getClass().getDeclaredField("chunkSize"); chunkSize = metric.getClass().getDeclaredField("chunkSize");
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
e.printStackTrace();
} }
} }

View File

@ -114,7 +114,7 @@ public class DbTestUtils {
if (!MemorySegmentUtils.isSupported()) { if (!MemorySegmentUtils.isSupported()) {
System.err.println("Warning! Foreign Memory Access API is not available!" System.err.println("Warning! Foreign Memory Access API is not available!"
+ " Netty direct buffers will not be used in tests!" + " Netty direct buffers will not be used in tests!"
+ " Please set \"--enable-preview --add-modules jdk.incubator.foreign --foreign.restricted=permit\""); + " Please set \"--enable-preview --add-modules jdk.incubator.foreign -Dforeign.restricted=permit\"");
if (MemorySegmentUtils.getUnsupportedCause() != null) { if (MemorySegmentUtils.getUnsupportedCause() != null) {
System.err.println("\tCause: " + MemorySegmentUtils.getUnsupportedCause().getClass().getName() System.err.println("\tCause: " + MemorySegmentUtils.getUnsupportedCause().getClass().getName()
+ ":" + MemorySegmentUtils.getUnsupportedCause().getLocalizedMessage()); + ":" + MemorySegmentUtils.getUnsupportedCause().getLocalizedMessage());