- ./gradlew clean nativeCompile
- ./build/native/nativeCompile/graalvm_gradle
Hello world! - task "jar" will also create a fat jar
java -jar build/libs/graalvm_gradle-1.0-SNAPSHOT.jar
java -cp build/libs/graalvm_gradle-1.0-SNAPSHOT.jar io.vertx.core.Launcher run org.example.MainVerticle
Added bucketloads of, and ...dependencies
From https://www.graalvm.org/22.2/reference-manual/native-image/guides/build-with-reflection/
-
mkdir -p META-INF/native-image
-
$JAVA_HOME/bin/java -cp build/libs/graalvm_gradle-1.0-SNAPSHOT.jar -agentlib:native-image-agent=config-output-dir=META-INF/native-image io.vertx.core.Launcher run org.example.MainVerticle
-
Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.orjni-config.jsonacle.graal.pointsto.constraints.UnsupportedFeatureException:
No instances of io.netty.util.internal.logging.Log4J2Logger are allowed in the image heap as this class should be initialized at image runtime.
To see how this object got instantiated use- --trace-oge bject-instantiation=io.netty.util.internal.logging.Log4J2Logger.
Fixed by pushing ALL of netty into runtime initialization
graalvmNative {
binaries {
main {
buildArgs.add('--initialize-at-run-time=io.netty')
}
}
}
- Disabled log4j
- //implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.20.0'
- Ran profiling to generate reflect-config.json (in META-INF subtree)
- Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException:
No instances of io.netty.util.internal.logging.Log4J2Logger are allowed in the image heap as this class should be initialized at image runtime.
To see how this object got instantiated use- --trace-object-instantiation=io.netty.util.internal.logging.Log4J2Logger.
- https://stackoverflow.com/questions/63328298/how-do-you-debug-a-no-instances-of-are-allowed-in-the-image-heap-when-buil
- --initialize-at-build-time=io.netty.util.internal.logging.Log4J2Logger
- --trace-object-instantiation=io.netty.util.internal.logging.Log4J2Logger.
- Object has been initialized by the io.netty.channel.nio.AbstractNioChannel class initializer
- Object has been initialized by the io.netty.channel.socket.nio.SelectorProviderUtil
- Object has been initialized by the io.netty.util.internal.PlatformDependent
- Object has been initialized by the io.netty.util.internal.PlatformDependent0
- Object has been initialized by the io.netty.util.internal.SystemPropertyUtil
- Object has been initialized by the io.netty.util.concurrent.FastThreadLocalThread
- Object has been initialized by the io.netty.channel.ChannelHandlerMask
- https://medium.com/graalvm/instant-netty-startup-using-graalvm-native-image-generation-ed6f14ff7692
- ss
- https://stackoverflow.com/questions/60654455/how-to-fix-try-avoiding-to-initialize-the-class-that-caused-initialization-wit
- ERROR StatusLogger Unable to load services for service class org.apache.logging.log4j.spi.Provider
java.lang.InternalError: com.oracle.svm.core.jdk.UnsupportedFeatureError: Defining hidden classes at runtime is not supported.