Skip to content

Fix native compilation with Netty 4.1.50 on GraalVM. #742

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

Merged
merged 2 commits into from
Jun 26, 2020

Conversation

michael-simons
Copy link
Contributor

@gsmet ping us in quarkusio/quarkus#10200 that the 4.1 driver fails to work with Quarkus in native mode. After investigation it is apparent that the failure is due to an upgrade to Netty 4.1.50.

To fix this, several things are needed:

  • Remove substitutions for io.netty.handler.ssl.Java9SslEngine

io.netty.handler.ssl.Java9SslEngine has been removed in Netty 4.1.50, Graal cannot substitute a class not on the classpath.

  • Remove task queue substitution and allow JCTools Mpsc queue to work.

This removes the substitution for the task queue in the io.netty.channel.nio.NioEventLoop class. Thus, the JCTools Mpsc queues will be used instead.

The Mpsc queues need a bit of reflection to work in native mode, but this is very isolated. Also, Netty upgraded to JCTools 3.0.0 in 4.1.46 and the Mpsc queues now are triggered during class initialition already, even with the substitution.
So we should live with the bits of reflection in native mode and remove the somewhat brittle substitution along the way.

This should be cherry picked into 4.0 as well.

I'll raise at least an issue for discussion with Netty regarding the reflection config for JCTools. cc @normanmaurer

`io.netty.handler.ssl.Java9SslEngine` has been removed in Netty 4.1.50, Graal cannot substitute a class not on the classpath.
This removes the substitution for the task queue in the `io.netty.channel.nio.NioEventLoop` class. Thus, the JCTools Mpsc will be used instead.

The Mpsc queues need a bit of reflection to work in native mode, but this is very isolated. Also, Netty upgraded to JCTools 3.0.0 in 4.1.46 and the Mpsc queues now are triggered during class initialition already, even with the substitution.
So we should live with the bits of reflection in native mode and remove the somewhat brittle substitution along the way.
@michael-simons michael-simons merged commit 9ed7d75 into neo4j:4.1 Jun 26, 2020
michael-simons added a commit to michael-simons/neo4j-java-driver that referenced this pull request Jun 26, 2020
Netty 4.1.50 needs two fixes for in our setup for native compilation on GraalVM:

* Remove substitutions for io.netty.handler.ssl.Java9SslEngine. as `io.netty.handler.ssl.Java9SslEngine` has been removed in Netty 4.1.50, Graal cannot substitute a class not on the classpath.

* Remove the substitution for the task queue in the `io.netty.channel.nio.NioEventLoop` class. Thus, the JCTools Mpsc will be used instead.

The Mpsc queues need a bit of reflection to work in native mode, but this is very isolated. Also, Netty upgraded to JCTools 3.0.0 in 4.1.46 and the Mpsc queues now are triggered during class initialition already, even with the substitution.
So we should live with the bits of reflection in native mode and remove the somewhat brittle substitution along the way.

Also it seems that the system property `io.netty.noUnsafe` which we set in the `native-image.properties` is not taken into account at all.
gjmwoods pushed a commit that referenced this pull request Jul 17, 2020
Netty 4.1.50 needs two fixes for in our setup for native compilation on GraalVM:

* Remove substitutions for io.netty.handler.ssl.Java9SslEngine. as `io.netty.handler.ssl.Java9SslEngine` has been removed in Netty 4.1.50, Graal cannot substitute a class not on the classpath.

* Remove the substitution for the task queue in the `io.netty.channel.nio.NioEventLoop` class. Thus, the JCTools Mpsc will be used instead.

The Mpsc queues need a bit of reflection to work in native mode, but this is very isolated. Also, Netty upgraded to JCTools 3.0.0 in 4.1.46 and the Mpsc queues now are triggered during class initialition already, even with the substitution.
So we should live with the bits of reflection in native mode and remove the somewhat brittle substitution along the way.

Also it seems that the system property `io.netty.noUnsafe` which we set in the `native-image.properties` is not taken into account at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants