Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netty update caused failure when building image with GraalVM for JDK 17 #39819

Closed
jedla97 opened this issue Apr 2, 2024 · 20 comments · Fixed by #39830
Closed

Netty update caused failure when building image with GraalVM for JDK 17 #39819

jedla97 opened this issue Apr 2, 2024 · 20 comments · Fixed by #39830
Labels
area/native-image kind/bug Something isn't working
Milestone

Comments

@jedla97
Copy link
Contributor

jedla97 commented Apr 2, 2024

Describe the bug

When building image containing quarkus-jdbc-postgresql the build failing on Performing analysis... step with error:

Error: Classes that should be initialized at run time got initialized during image building:
 io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf the class was requested to be initialized at run time (subtype of io.netty.buffer.AbstractReferenceCountedByteBuf). To see why io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf got initialized use --trace-class-initialization=io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf
io.netty.buffer.UnpooledDirectByteBuf the class was requested to be initialized at run time (subtype of io.netty.buffer.AbstractReferenceCountedByteBuf). To see why io.netty.buffer.UnpooledDirectByteBuf got initialized use --trace-class-initialization=io.netty.buffer.UnpooledDirectByteBuf
org.jctools.util.UnsafeRefArrayAccess the class was requested to be initialized at run time (from feature io.quarkus.runner.Feature.beforeAnalysis with ''). To see why org.jctools.util.UnsafeRefArrayAccess got initialized use --trace-class-initialization=org.jctools.util.UnsafeRefArrayAccess
io.netty.buffer.UnpooledUnsafeDirectByteBuf the class was requested to be initialized at run time (subtype of io.netty.buffer.AbstractReferenceCountedByteBuf). To see why io.netty.buffer.UnpooledUnsafeDirectByteBuf got initialized use --trace-class-initialization=io.netty.buffer.UnpooledUnsafeDirectByteBuf
io.netty.buffer.UnpooledUnsafeHeapByteBuf the class was requested to be initialized at run time (subtype of io.netty.buffer.AbstractReferenceCountedByteBuf). To see why io.netty.buffer.UnpooledUnsafeHeapByteBuf got initialized use --trace-class-initialization=io.netty.buffer.UnpooledUnsafeHeapByteBuf
io.netty.buffer.UnpooledHeapByteBuf the class was requested to be initialized at run time (subtype of io.netty.buffer.AbstractReferenceCountedByteBuf). To see why io.netty.buffer.UnpooledHeapByteBuf got initialized use --trace-class-initialization=io.netty.buffer.UnpooledHeapByteBuf
io.netty.buffer.ByteBufUtil the class was requested to be initialized at run time (from 'META-INF/native-image/io.netty/netty-buffer/native-image.properties' in 'file:///home/jjedlick/work/quarkus-reproducers/target/quarkus-reproducers-1.0.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-buffer-4.1.108.Final.jar' with 'io.netty.buffer.ByteBufUtil' and from feature io.quarkus.runner.Feature.beforeAnalysis with 'ByteBufUtil.class'). To see why io.netty.buffer.ByteBufUtil got initialized use --trace-class-initialization=io.netty.buffer.ByteBufUtil
io.netty.buffer.PooledByteBufAllocator the class was requested to be initialized at run time (from 'META-INF/native-image/io.netty/netty-buffer/native-image.properties' in 'file:///home/jjedlick/work/quarkus-reproducers/target/quarkus-reproducers-1.0.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-buffer-4.1.108.Final.jar' with 'io.netty.buffer.PooledByteBufAllocator' and from feature io.quarkus.runner.Feature.beforeAnalysis with 'PooledByteBufAllocator.class'). To see why io.netty.buffer.PooledByteBufAllocator got initialized use --trace-class-initialization=io.netty.buffer.PooledByteBufAllocator
io.netty.buffer.AbstractReferenceCountedByteBuf the class was requested to be initialized at run time (from 'META-INF/native-image/io.netty/netty-buffer/native-image.properties' in 'file:///home/jjedlick/work/quarkus-reproducers/target/quarkus-reproducers-1.0.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-buffer-4.1.108.Final.jar' with 'io.netty.buffer.AbstractReferenceCountedByteBuf'). To see why io.netty.buffer.AbstractReferenceCountedByteBuf got initialized use --trace-class-initialization=io.netty.buffer.AbstractReferenceCountedByteBuf
io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeDirectByteBuf the class was requested to be initialized at run time (subtype of io.netty.buffer.AbstractReferenceCountedByteBuf). To see why io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeDirectByteBuf got initialized use --trace-class-initialization=io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeDirectByteBuf
To see how the classes got initialized, use --trace-class-initialization=io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf,io.netty.buffer.UnpooledDirectByteBuf,org.jctools.util.UnsafeRefArrayAccess,io.netty.buffer.UnpooledUnsafeDirectByteBuf,io.netty.buffer.UnpooledUnsafeHeapByteBuf,io.netty.buffer.UnpooledHeapByteBuf,io.netty.buffer.ByteBufUtil,io.netty.buffer.PooledByteBufAllocator,io.netty.buffer.AbstractReferenceCountedByteBuf,io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeDirectByteBuf
com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
 io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf the class was requested to be initialized at run time (subtype of io.netty.buffer.AbstractReferenceCountedByteBuf). To see why io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf got initialized use --trace-class-initialization=io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf
io.netty.buffer.UnpooledDirectByteBuf the class was requested to be initialized at run time (subtype of io.netty.buffer.AbstractReferenceCountedByteBuf). To see why io.netty.buffer.UnpooledDirectByteBuf got initialized use --trace-class-initialization=io.netty.buffer.UnpooledDirectByteBuf
org.jctools.util.UnsafeRefArrayAccess the class was requested to be initialized at run time (from feature io.quarkus.runner.Feature.beforeAnalysis with ''). To see why org.jctools.util.UnsafeRefArrayAccess got initialized use --trace-class-initialization=org.jctools.util.UnsafeRefArrayAccess
io.netty.buffer.UnpooledUnsafeDirectByteBuf the class was requested to be initialized at run time (subtype of io.netty.buffer.AbstractReferenceCountedByteBuf). To see why io.netty.buffer.UnpooledUnsafeDirectByteBuf got initialized use --trace-class-initialization=io.netty.buffer.UnpooledUnsafeDirectByteBuf
io.netty.buffer.UnpooledUnsafeHeapByteBuf the class was requested to be initialized at run time (subtype of io.netty.buffer.AbstractReferenceCountedByteBuf). To see why io.netty.buffer.UnpooledUnsafeHeapByteBuf got initialized use --trace-class-initialization=io.netty.buffer.UnpooledUnsafeHeapByteBuf
io.netty.buffer.UnpooledHeapByteBuf the class was requested to be initialized at run time (subtype of io.netty.buffer.AbstractReferenceCountedByteBuf). To see why io.netty.buffer.UnpooledHeapByteBuf got initialized use --trace-class-initialization=io.netty.buffer.UnpooledHeapByteBuf
io.netty.buffer.ByteBufUtil the class was requested to be initialized at run time (from 'META-INF/native-image/io.netty/netty-buffer/native-image.properties' in 'file:///home/jjedlick/work/quarkus-reproducers/target/quarkus-reproducers-1.0.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-buffer-4.1.108.Final.jar' with 'io.netty.buffer.ByteBufUtil' and from feature io.quarkus.runner.Feature.beforeAnalysis with 'ByteBufUtil.class'). To see why io.netty.buffer.ByteBufUtil got initialized use --trace-class-initialization=io.netty.buffer.ByteBufUtil
io.netty.buffer.PooledByteBufAllocator the class was requested to be initialized at run time (from 'META-INF/native-image/io.netty/netty-buffer/native-image.properties' in 'file:///home/jjedlick/work/quarkus-reproducers/target/quarkus-reproducers-1.0.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-buffer-4.1.108.Final.jar' with 'io.netty.buffer.PooledByteBufAllocator' and from feature io.quarkus.runner.Feature.beforeAnalysis with 'PooledByteBufAllocator.class'). To see why io.netty.buffer.PooledByteBufAllocator got initialized use --trace-class-initialization=io.netty.buffer.PooledByteBufAllocator
io.netty.buffer.AbstractReferenceCountedByteBuf the class was requested to be initialized at run time (from 'META-INF/native-image/io.netty/netty-buffer/native-image.properties' in 'file:///home/jjedlick/work/quarkus-reproducers/target/quarkus-reproducers-1.0.0-SNAPSHOT-native-image-source-jar/lib/io.netty.netty-buffer-4.1.108.Final.jar' with 'io.netty.buffer.AbstractReferenceCountedByteBuf'). To see why io.netty.buffer.AbstractReferenceCountedByteBuf got initialized use --trace-class-initialization=io.netty.buffer.AbstractReferenceCountedByteBuf
io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeDirectByteBuf the class was requested to be initialized at run time (subtype of io.netty.buffer.AbstractReferenceCountedByteBuf). To see why io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeDirectByteBuf got initialized use --trace-class-initialization=io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeDirectByteBuf
To see how the classes got initialized, use --trace-class-initialization=io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf,io.netty.buffer.UnpooledDirectByteBuf,org.jctools.util.UnsafeRefArrayAccess,io.netty.buffer.UnpooledUnsafeDirectByteBuf,io.netty.buffer.UnpooledUnsafeHeapByteBuf,io.netty.buffer.UnpooledHeapByteBuf,io.netty.buffer.ByteBufUtil,io.netty.buffer.PooledByteBufAllocator,io.netty.buffer.AbstractReferenceCountedByteBuf,io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeDirectByteBuf
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:73)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.ProvenSafeClassInitializationSupport.checkDelayedInitialization(ProvenSafeClassInitializationSupport.java:273)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:164)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$10(NativeImageGenerator.java:748)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:85)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$11(NativeImageGenerator.java:748)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.AbstractAnalysisEngine.runAnalysis(AbstractAnalysisEngine.java:162)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:745)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:578)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:535)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:580)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)

It was caused probably by #39764 (not tested it without this commit) and it's probably same or simillar problem as in #39788 PR.

This seems only affecting jdk 17 not jdk 21.

Looking at GeaalVM info for jdk 17:

Version info: 'GraalVM 22.3.2 Java 17 CE'
 Java version info: '17.0.7+7-jvmci-22.3-b18'
 C compiler: gcc (redhat, x86_64, 13.2.1)

for jdk 21:

Java version: 21.0.2+13-LTS, vendor version: Mandrel-23.1.2.0-Final
 Graal compiler: optimization level: 2, target machine: x86-64-v3
 C compiler: gcc (redhat, x86_64, 8.5.0)

Both GraalVM version is pulled automatically as I'm using openjdk

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

  1. Build of Quarkus main branch
  2. git clone -b netty-native [email protected]:jedla97/quarkus-reproducers.git
  3. cd quarkus-reproducers
  4. ./mvnw package -Dnative

Output of uname -a or ver

No response

Output of java -version

No response

Mandrel or GraalVM version (if different from Java)

No response

Quarkus version or git rev

main/999-SNAPSHOT

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@jedla97 jedla97 added area/native-image kind/bug Something isn't working labels Apr 2, 2024
Copy link

quarkus-bot bot commented Apr 2, 2024

/cc @Karm (mandrel), @galderz (mandrel), @zakkak (mandrel)

@zakkak zakkak changed the title Netty update caused failure when building image Netty update caused failure when building image with GraalVM for JDK 17 Apr 2, 2024
@jponge
Copy link
Member

jponge commented Apr 2, 2024

/cc @geoand

@geoand
Copy link
Contributor

geoand commented Apr 2, 2024

Nice :)

@geoand
Copy link
Contributor

geoand commented Apr 2, 2024

I assume we should also add the change you made in your PR to main @jponge

@jponge
Copy link
Member

jponge commented Apr 2, 2024

I'm looking into the reproducer and will check

@geoand
Copy link
Contributor

geoand commented Apr 2, 2024

🙏🏼

@jponge
Copy link
Member

jponge commented Apr 2, 2024

Confirmed this happens on 17 and not 21 😞

@geoand
Copy link
Contributor

geoand commented Apr 2, 2024

Interesting

@gsmet
Copy link
Member

gsmet commented Apr 2, 2024

@zakkak do we still support building with GraalVM for Java 17?

@jponge
Copy link
Member

jponge commented Apr 2, 2024

With 17 I've been able to shelve a few issues by adding these 2 classes, just like in my 3.2 backport branch

diff --git a/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java b/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java
index a7d5ae3e2c2..4c2741d2092 100644
--- a/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java
+++ b/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java
@@ -105,6 +105,8 @@ NativeImageConfigBuildItem build(
                 .addRuntimeInitializedClass("io.netty.handler.ssl.ReferenceCountedOpenSslEngine")
                 .addRuntimeInitializedClass("io.netty.handler.ssl.ReferenceCountedOpenSslContext")
                 .addRuntimeInitializedClass("io.netty.handler.ssl.ReferenceCountedOpenSslClientContext")
+                .addRuntimeInitializedClass("io.netty.handler.ssl.JdkSslServerContext")
+                .addRuntimeInitializedClass("io.netty.handler.ssl.JdkSslClientContext")
                 .addRuntimeInitializedClass("io.netty.handler.ssl.util.ThreadLocalInsecureRandom")
                 .addRuntimeInitializedClass("io.netty.buffer.ByteBufUtil$HexUtil")
                 .addRuntimeInitializedClass("io.netty.buffer.PooledByteBufAllocator")

Now the newly added Mutiny native integration tests fail on 17 with the remaining issue (I had tested with 21, just like in CI)

Error: Classes that should be initialized at run time got initialized during image building:
 org.jctools.util.UnsafeRefArrayAccess the class was requested to be initialized at run time (from feature io.quarkus.runner.Feature.beforeAnalysis with ''). org.jctools.util.UnsafeRefArrayAccess caused initialization of this class with the following trace:
	at org.jctools.util.UnsafeRefArrayAccess.<clinit>(UnsafeRefArrayAccess.java:26)
	at java.lang.Class.forName0(Unknown Source)
	at java.lang.Class.forName(Class.java:375)
	at io.quarkus.runner.Feature.registerAsUnsafeAccessed(Unknown Source)
	at io.quarkus.runner.Feature.beforeAnalysis(Unknown Source)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$9(NativeImageGenerator.java:757)
	at com.oracle.svm.hosted.NativeImageGenerator$$Lambda$578/0x000000a00172b718.accept(Unknown Source)
	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:89)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:757)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:582)
	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:539)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:408)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:612)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:134)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:94)

This one looks tricky

@cescoffier
Copy link
Member

It's tricky because this class must not be loaded (initialized) at runtime as it loads buffers (which are machine-dependent). At the same time, to register for Unusafe access, the class must be loaded...

@jponge
Copy link
Member

jponge commented Apr 2, 2024

And 21 is fine, not 17 🤦

@jponge
Copy link
Member

jponge commented Apr 2, 2024

To be exhaustive:

./mvnw clean verify -f integration-tests/mutiny-native-jctools -Pnative -Dquarkus.native.additional-build-args=--trace-class-initialization=org.jctools.util.UnsafeRefArrayAccess

yields:

Error: Classes that should be initialized at run time got initialized during image building:
 org.jctools.util.UnsafeRefArrayAccess the class was requested to be initialized at run time (from feature io.quarkus.runner.Feature.beforeAnalysis with ''). org.jctools.util.UnsafeRefArrayAccess caused initialization of this class with the following trace:
	at org.jctools.util.UnsafeRefArrayAccess.<clinit>(UnsafeRefArrayAccess.java:26)
	at java.lang.Class.forName0(Unknown Source)
	at java.lang.Class.forName(Class.java:375)
	at io.quarkus.runner.Feature.registerAsUnsafeAccessed(Unknown Source)
	at io.quarkus.runner.Feature.beforeAnalysis(Unknown Source)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$9(NativeImageGenerator.java:757)
	at com.oracle.svm.hosted.NativeImageGenerator$$Lambda$578/0x000000a00172b718.accept(Unknown Source)
	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:89)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:757)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:582)
	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:539)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:408)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:612)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:134)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:94)


com.oracle.svm.core.util.UserError$UserException: Classes that should be initialized at run time got initialized during image building:
 org.jctools.util.UnsafeRefArrayAccess the class was requested to be initialized at run time (from feature io.quarkus.runner.Feature.beforeAnalysis with ''). org.jctools.util.UnsafeRefArrayAccess caused initialization of this class with the following trace:
	at org.jctools.util.UnsafeRefArrayAccess.<clinit>(UnsafeRefArrayAccess.java:26)
	at java.lang.Class.forName0(Unknown Source)
	at java.lang.Class.forName(Class.java:375)
	at io.quarkus.runner.Feature.registerAsUnsafeAccessed(Unknown Source)
	at io.quarkus.runner.Feature.beforeAnalysis(Unknown Source)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$9(NativeImageGenerator.java:757)
	at com.oracle.svm.hosted.NativeImageGenerator$$Lambda$578/0x000000a00172b718.accept(Unknown Source)
	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:89)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:757)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:582)
	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:539)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:408)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:612)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:134)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:94)


	at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:73)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.ProvenSafeClassInitializationSupport.checkDelayedInitialization(ProvenSafeClassInitializationSupport.java:277)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.duringAnalysis(ClassInitializationFeature.java:164)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$10(NativeImageGenerator.java:770)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:89)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$11(NativeImageGenerator.java:770)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.AbstractAnalysisEngine.runAnalysis(AbstractAnalysisEngine.java:179)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:767)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:582)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:539)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:408)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:612)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.start(NativeImageGeneratorRunner.java:134)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:94)

@cescoffier
Copy link
Member

So, it uses the Quarkus feature to register the unsafe access. This feature requires loading the class (at build time) to extract the Unsafe field.

I'm not sure, but we may be able to do that differently without the Quarkus feature (using plain old metadata).

What's suspicious is that only org.jctools.util.UnsafeAccess.UNSAFE should be registered for unsafe access, not UnsafeRefArrayAccess

@jponge
Copy link
Member

jponge commented Apr 2, 2024

You need to register UnsafeRefArrayAccess because GraalVM can't automatically compute the access to REF_ELEMENT_SHIFT

@jponge
Copy link
Member

jponge commented Apr 2, 2024

Ok, so... removing all UnsafeAccessedFieldBuildItem for JCTools now works for both 17/21 with JdkSslServerContext and JdkSslClientContext being runtime-initialized.

I'm getting mad 🤣

jponge added a commit to jponge/quarkus that referenced this issue Apr 2, 2024
@jponge jponge linked a pull request Apr 2, 2024 that will close this issue
@zakkak
Copy link
Contributor

zakkak commented Apr 2, 2024

@zakkak do we still support building with GraalVM for Java 17?

AFAIK GraalVM for Java 17 support is on "best effort" mode. We prefer to keep it working since it allows us to do cross-version comparisons but shouldn't be a blocker, i.e. if something is essential to Quarkus and breaks GraalVM for Java 17 compatibility it's OK.

cc @jerboaa @Karm @galderz

jponge added a commit to jponge/quarkus that referenced this issue Apr 2, 2024
@jerboaa
Copy link
Contributor

jerboaa commented Apr 2, 2024

To me this would be a quarkus decision. It seems fine to only support GraalVM for JDK 21 and GraalVM for JDK 22 for quarkus main. Quarkus 3.2 needs to support GraalVM for JDK 17.

@geoand
Copy link
Contributor

geoand commented Apr 2, 2024

cc @maxandersen @tqvarnst

@jponge
Copy link
Member

jponge commented Apr 2, 2024

Note: I'm still working on a fix that'd work for 17 + 21 😉

@gsmet gsmet modified the milestones: 3.10 - main, 3.9.3 Apr 9, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 9, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 9, 2024
@gsmet gsmet modified the milestones: 3.9.3, 3.8.4 Apr 9, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 9, 2024
See quarkusio#39819 and quarkusio#39788

(cherry picked from commit b35ae00)
(cherry picked from commit d2673c8)
fabricepipart1a added a commit to fabricepipart1a/quarkus-java-sample-cli that referenced this issue Apr 10, 2024
fabricepipart1a added a commit to fabricepipart1a/quarkus-java-sample-cli that referenced this issue Apr 10, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 11, 2024
See quarkusio#39819 and quarkusio#39788

(cherry picked from commit b35ae00)
(cherry picked from commit d2673c8)
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 11, 2024
See quarkusio#39819 and quarkusio#39788

(cherry picked from commit b35ae00)
(cherry picked from commit d2673c8)
ketola pushed a commit to ketola/quarkus that referenced this issue May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/native-image kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants