|
22 | 22 | import com.oracle.svm.core.annotate.Substitute;
|
23 | 23 | import com.oracle.svm.core.annotate.TargetClass;
|
24 | 24 | import com.oracle.svm.core.jdk.JDK11OrLater;
|
| 25 | +import com.oracle.svm.core.jdk.JDK8OrEarlier; |
25 | 26 |
|
26 | 27 | import java.security.PrivateKey;
|
27 | 28 | import java.security.Provider;
|
28 | 29 | import java.security.cert.X509Certificate;
|
29 |
| -import java.util.Queue; |
30 |
| -import java.util.concurrent.LinkedBlockingDeque; |
31 | 30 | import javax.net.ssl.KeyManagerFactory;
|
32 | 31 | import javax.net.ssl.SSLEngine;
|
33 | 32 | import javax.net.ssl.SSLException;
|
@@ -113,20 +112,58 @@ final class Target_io_netty_handler_ssl_SslHandler$SslEngineType {
|
113 | 112 | @TargetClass(className = "io.netty.handler.ssl.JdkAlpnApplicationProtocolNegotiator$AlpnWrapper", onlyWith = JDK11OrLater.class)
|
114 | 113 | final class Target_io_netty_handler_ssl_JdkAlpnApplicationProtocolNegotiator_AlpnWrapper {
|
115 | 114 | @Substitute
|
116 |
| - @SuppressWarnings( "deprecation" ) |
117 |
| - public SSLEngine wrapSslEngine( SSLEngine engine, ByteBufAllocator alloc, |
| 115 | + public SSLEngine wrapSslEngine(SSLEngine engine, ByteBufAllocator alloc, |
| 116 | + JdkApplicationProtocolNegotiator applicationNegotiator, boolean isServer) { |
| 117 | + return (SSLEngine) (Object) new Target_io_netty_handler_ssl_JdkAlpnSslEngine(engine, applicationNegotiator, isServer); |
| 118 | + } |
| 119 | + |
| 120 | +} |
| 121 | + |
| 122 | +@TargetClass(className = "io.netty.handler.ssl.JdkAlpnApplicationProtocolNegotiator$AlpnWrapper", onlyWith = JDK8OrEarlier.class) |
| 123 | +final class Target_io_netty_handler_ssl_JdkAlpnApplicationProtocolNegotiator_AlpnWrapperJava8 { |
| 124 | + @Substitute |
| 125 | + public SSLEngine wrapSslEngine(SSLEngine engine, ByteBufAllocator alloc, |
118 | 126 | JdkApplicationProtocolNegotiator applicationNegotiator, boolean isServer) {
|
119 |
| - return (SSLEngine) (Object) new Target_io_netty_handler_ssl_Java9SslEngine( |
120 |
| - engine, applicationNegotiator, isServer); |
| 127 | + if (Target_io_netty_handler_ssl_JettyAlpnSslEngine.isAvailable()) { |
| 128 | + return isServer |
| 129 | + ? (SSLEngine) (Object) Target_io_netty_handler_ssl_JettyAlpnSslEngine.newServerEngine(engine, |
| 130 | + applicationNegotiator) |
| 131 | + : (SSLEngine) (Object) Target_io_netty_handler_ssl_JettyAlpnSslEngine.newClientEngine(engine, |
| 132 | + applicationNegotiator); |
| 133 | + } |
| 134 | + throw new RuntimeException("Unable to wrap SSLEngine of type " + engine.getClass().getName()); |
121 | 135 | }
|
122 | 136 |
|
123 | 137 | }
|
124 | 138 |
|
125 |
| -@TargetClass(className = "io.netty.handler.ssl.Java9SslEngine", onlyWith = JDK11OrLater.class) |
126 |
| -final class Target_io_netty_handler_ssl_Java9SslEngine { |
| 139 | +@TargetClass(className = "io.netty.handler.ssl.JettyAlpnSslEngine", onlyWith = JDK8OrEarlier.class) |
| 140 | +final class Target_io_netty_handler_ssl_JettyAlpnSslEngine { |
| 141 | + @Substitute |
| 142 | + static boolean isAvailable() { |
| 143 | + return false; |
| 144 | + } |
| 145 | + |
| 146 | + @Substitute |
| 147 | + @SuppressWarnings( "deprecation" ) |
| 148 | + static Target_io_netty_handler_ssl_JettyAlpnSslEngine newClientEngine(SSLEngine engine, |
| 149 | + JdkApplicationProtocolNegotiator applicationNegotiator) { |
| 150 | + return null; |
| 151 | + } |
| 152 | + |
| 153 | + @Substitute |
| 154 | + @SuppressWarnings( "deprecation" ) |
| 155 | + static Target_io_netty_handler_ssl_JettyAlpnSslEngine newServerEngine(SSLEngine engine, |
| 156 | + JdkApplicationProtocolNegotiator applicationNegotiator) { |
| 157 | + return null; |
| 158 | + } |
| 159 | +} |
| 160 | + |
| 161 | +@TargetClass(className = "io.netty.handler.ssl.JdkAlpnSslEngine", onlyWith = JDK11OrLater.class) |
| 162 | +final class Target_io_netty_handler_ssl_JdkAlpnSslEngine { |
| 163 | + |
127 | 164 | @Alias
|
128 | 165 | @SuppressWarnings( "deprecation" )
|
129 |
| - Target_io_netty_handler_ssl_Java9SslEngine(final SSLEngine engine, |
| 166 | + Target_io_netty_handler_ssl_JdkAlpnSslEngine(final SSLEngine engine, |
130 | 167 | final JdkApplicationProtocolNegotiator applicationNegotiator, final boolean isServer) {
|
131 | 168 |
|
132 | 169 | }
|
@@ -298,15 +335,5 @@ final ChannelFuture initAndRegister() {
|
298 | 335 | }
|
299 | 336 | }
|
300 | 337 |
|
301 |
| -@TargetClass(className = "io.netty.channel.nio.NioEventLoop") |
302 |
| -final class Target_io_netty_channel_nio_NioEventLoop { |
303 |
| - |
304 |
| - @Substitute |
305 |
| - private static Queue<Runnable> newTaskQueue0(int maxPendingTasks) { |
306 |
| - return new LinkedBlockingDeque<>(); |
307 |
| - } |
308 |
| -} |
309 |
| - |
310 | 338 | class NettySubstitutions {
|
311 |
| - |
312 | 339 | }
|
0 commit comments