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
ee207f4bc6
commit
3875bb92b4
@ -70,6 +70,7 @@ public final class PlatformDependent {
|
|||||||
private static final boolean IS_WINDOWS = isWindows0();
|
private static final boolean IS_WINDOWS = isWindows0();
|
||||||
private static final boolean IS_OSX = isOsx0();
|
private static final boolean IS_OSX = isOsx0();
|
||||||
private static final boolean IS_J9_JVM = isJ9Jvm0();
|
private static final boolean IS_J9_JVM = isJ9Jvm0();
|
||||||
|
private static final boolean IS_IVKVM_DOT_NET = isIkvmDotNet0();
|
||||||
|
|
||||||
private static final boolean MAYBE_SUPER_USER;
|
private static final boolean MAYBE_SUPER_USER;
|
||||||
|
|
||||||
@ -867,6 +868,12 @@ public final class PlatformDependent {
|
|||||||
logger.debug("sun.misc.Unsafe: unavailable (Android)");
|
logger.debug("sun.misc.Unsafe: unavailable (Android)");
|
||||||
return new UnsupportedOperationException("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();
|
Throwable cause = PlatformDependent0.getUnsafeUnavailabilityCause();
|
||||||
if (cause != null) {
|
if (cause != null) {
|
||||||
return cause;
|
return cause;
|
||||||
@ -896,6 +903,18 @@ public final class PlatformDependent {
|
|||||||
return vmName.startsWith("ibm j9") || vmName.startsWith("eclipse openj9");
|
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() {
|
private static long maxDirectMemory0() {
|
||||||
long maxDirectMemory = 0;
|
long maxDirectMemory = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user