Don't use sun.misc.Unsafe when IKVM.NET is used (#9042)
Motivation: IKVM.NET seems to ship a bug sun.misc.Unsafe class, for this reason we should better disable our sun.misc.Unsafe usage when we detect IKVM.NET is used. Modifications: Check if IKVM.NET is used and if so do not use sun.misc.Unsafe by default. Result: Fixes https://github.com/netty/netty/issues/9035 and https://github.com/netty/netty/issues/8916.
This commit is contained in:
parent
48edf40861
commit
34aa2c841c
@ -75,6 +75,7 @@ public final class PlatformDependent {
|
||||
private static final boolean IS_WINDOWS = isWindows0();
|
||||
private static final boolean IS_OSX = isOsx0();
|
||||
private static final boolean IS_J9_JVM = isJ9Jvm0();
|
||||
private static final boolean IS_IVKVM_DOT_NET = isIkvmDotNet0();
|
||||
|
||||
private static final boolean MAYBE_SUPER_USER;
|
||||
|
||||
@ -953,6 +954,12 @@ public final class PlatformDependent {
|
||||
logger.debug("sun.misc.Unsafe: unavailable (Android)");
|
||||
return new UnsupportedOperationException("sun.misc.Unsafe: unavailable (Android)");
|
||||
}
|
||||
|
||||
if (isIkvmDotNet()) {
|
||||
logger.debug("sun.misc.Unsafe: unavailable (IKVM.NET)");
|
||||
return new UnsupportedOperationException("sun.misc.Unsafe: unavailable (IKVM.NET)");
|
||||
}
|
||||
|
||||
Throwable cause = PlatformDependent0.getUnsafeUnavailabilityCause();
|
||||
if (cause != null) {
|
||||
return cause;
|
||||
@ -982,6 +989,18 @@ public final class PlatformDependent {
|
||||
return vmName.startsWith("ibm j9") || vmName.startsWith("eclipse openj9");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the running JVM is <a href="https://www.ikvm.net">IKVM.NET</a>, {@code false} otherwise.
|
||||
*/
|
||||
public static boolean isIkvmDotNet() {
|
||||
return IS_IVKVM_DOT_NET;
|
||||
}
|
||||
|
||||
private static boolean isIkvmDotNet0() {
|
||||
String vmName = SystemPropertyUtil.get("java.vm.name", "").toUpperCase(Locale.US);
|
||||
return vmName.equals("IKVM.NET");
|
||||
}
|
||||
|
||||
private static long maxDirectMemory0() {
|
||||
long maxDirectMemory = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user