0601389766
Motivation: GraalVM's native images built with native-image tool do not support Unsafe.staticFieldOffset() method (at least, currently). If an application using Netty (and causing initialization of io.netty.util.internal.PlatformDependent0 class) is built into a native image and run, this results in the following error thrown during initialization: Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: Unsupported method of Unsafe at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:86) at jdk.internal.misc.Unsafe.staticFieldOffset(Unsafe.java:230) at sun.misc.Unsafe.staticFieldOffset(Unsafe.java:662) at io.netty.util.internal.PlatformDependent0$5.run(PlatformDependent0.java:294) at java.security.AccessController.doPrivileged(AccessController.java:83) at io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:279) This seems to be the reason of the behavior described in #10051. Modification: The idea of this commit is to only invoke Unsafe.staticFieldOffset() is we are not in a native image; if we are, behave like if we could not find the field at all. GraalDetector is borrowed from Spring framework. Result: Fixes #10051 |
||
---|---|---|
.. | ||
src | ||
pom.xml |