Skip to content

Fix native compilation with Netty 4.1.50 on GraalVM. #743

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 1 commit into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.jdk.JDK11OrLater;
import com.oracle.svm.core.jdk.JDK8OrEarlier;

import java.security.PrivateKey;
import java.security.Provider;
import java.security.cert.X509Certificate;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingDeque;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLException;
Expand Down Expand Up @@ -113,20 +112,58 @@ final class Target_io_netty_handler_ssl_SslHandler$SslEngineType {
@TargetClass(className = "io.netty.handler.ssl.JdkAlpnApplicationProtocolNegotiator$AlpnWrapper", onlyWith = JDK11OrLater.class)
final class Target_io_netty_handler_ssl_JdkAlpnApplicationProtocolNegotiator_AlpnWrapper {
@Substitute
@SuppressWarnings( "deprecation" )
public SSLEngine wrapSslEngine( SSLEngine engine, ByteBufAllocator alloc,
public SSLEngine wrapSslEngine(SSLEngine engine, ByteBufAllocator alloc,
JdkApplicationProtocolNegotiator applicationNegotiator, boolean isServer) {
return (SSLEngine) (Object) new Target_io_netty_handler_ssl_JdkAlpnSslEngine(engine, applicationNegotiator, isServer);
}

}

@TargetClass(className = "io.netty.handler.ssl.JdkAlpnApplicationProtocolNegotiator$AlpnWrapper", onlyWith = JDK8OrEarlier.class)
final class Target_io_netty_handler_ssl_JdkAlpnApplicationProtocolNegotiator_AlpnWrapperJava8 {
@Substitute
public SSLEngine wrapSslEngine(SSLEngine engine, ByteBufAllocator alloc,
JdkApplicationProtocolNegotiator applicationNegotiator, boolean isServer) {
return (SSLEngine) (Object) new Target_io_netty_handler_ssl_Java9SslEngine(
engine, applicationNegotiator, isServer);
if (Target_io_netty_handler_ssl_JettyAlpnSslEngine.isAvailable()) {
return isServer
? (SSLEngine) (Object) Target_io_netty_handler_ssl_JettyAlpnSslEngine.newServerEngine(engine,
applicationNegotiator)
: (SSLEngine) (Object) Target_io_netty_handler_ssl_JettyAlpnSslEngine.newClientEngine(engine,
applicationNegotiator);
}
throw new RuntimeException("Unable to wrap SSLEngine of type " + engine.getClass().getName());
}

}

@TargetClass(className = "io.netty.handler.ssl.Java9SslEngine", onlyWith = JDK11OrLater.class)
final class Target_io_netty_handler_ssl_Java9SslEngine {
@TargetClass(className = "io.netty.handler.ssl.JettyAlpnSslEngine", onlyWith = JDK8OrEarlier.class)
final class Target_io_netty_handler_ssl_JettyAlpnSslEngine {
@Substitute
static boolean isAvailable() {
return false;
}

@Substitute
@SuppressWarnings( "deprecation" )
static Target_io_netty_handler_ssl_JettyAlpnSslEngine newClientEngine(SSLEngine engine,
JdkApplicationProtocolNegotiator applicationNegotiator) {
return null;
}

@Substitute
@SuppressWarnings( "deprecation" )
static Target_io_netty_handler_ssl_JettyAlpnSslEngine newServerEngine(SSLEngine engine,
JdkApplicationProtocolNegotiator applicationNegotiator) {
return null;
}
}

@TargetClass(className = "io.netty.handler.ssl.JdkAlpnSslEngine", onlyWith = JDK11OrLater.class)
final class Target_io_netty_handler_ssl_JdkAlpnSslEngine {

@Alias
@SuppressWarnings( "deprecation" )
Target_io_netty_handler_ssl_Java9SslEngine(final SSLEngine engine,
Target_io_netty_handler_ssl_JdkAlpnSslEngine(final SSLEngine engine,
final JdkApplicationProtocolNegotiator applicationNegotiator, final boolean isServer) {

}
Expand Down Expand Up @@ -298,15 +335,5 @@ final ChannelFuture initAndRegister() {
}
}

@TargetClass(className = "io.netty.channel.nio.NioEventLoop")
final class Target_io_netty_channel_nio_NioEventLoop {

@Substitute
private static Queue<Runnable> newTaskQueue0(int maxPendingTasks) {
return new LinkedBlockingDeque<>();
}
}

class NettySubstitutions {

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,41 @@
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.ReferenceCountUtil",
"allDeclaredMethods" : true
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueProducerIndexField",
"fields": [
{"name": "producerIndex", "allowUnsafeAccess": true}
]
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueProducerLimitField",
"fields": [
{"name": "producerLimit", "allowUnsafeAccess": true}
]
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueConsumerIndexField",
"fields": [
{"name": "consumerIndex", "allowUnsafeAccess": true}
]
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueProducerFields",
"fields": [
{"name": "producerIndex", "allowUnsafeAccess": true}
]
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueColdProducerFields",
"fields": [
{"name": "producerLimit", "allowUnsafeAccess": true}
]
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueConsumerFields",
"fields": [
{"name": "consumerIndex", "allowUnsafeAccess": true}
]
}
]