|
50 | 50 | @Platforms({InternalPlatform.PLATFORM_JNI.class})
|
51 | 51 | @AutomaticFeature
|
52 | 52 | class JNIRegistrationJavaNet extends JNIRegistrationUtil implements Feature {
|
53 |
| - |
54 |
| - private boolean hasExtendedOptionsImpl; |
55 | 53 | private boolean hasPlatformSocketOptions;
|
56 | 54 |
|
57 | 55 | @Override
|
58 | 56 | public void duringSetup(DuringSetupAccess a) {
|
59 |
| - hasExtendedOptionsImpl = a.findClassByName("sun.net.ExtendedOptionsImpl") != null; |
60 |
| - hasPlatformSocketOptions = a.findClassByName("jdk.net.ExtendedSocketOptions$PlatformSocketOptions") != null; |
61 |
| - |
| 57 | + /* jdk.net.ExtendedSocketOptions is only available if the jdk.net module is loaded. */ |
| 58 | + this.hasPlatformSocketOptions = a.findClassByName("jdk.net.ExtendedSocketOptions$PlatformSocketOptions") != null; |
62 | 59 | rerunClassInit(a, "java.net.DatagramPacket", "java.net.InetAddress", "java.net.NetworkInterface",
|
63 | 60 | /* Stores a default SSLContext in a static field. */
|
64 | 61 | "javax.net.ssl.SSLContext");
|
65 |
| - if (JavaVersionUtil.JAVA_SPEC <= 17) { |
| 62 | + if (JavaVersionUtil.JAVA_SPEC < 19) { |
66 | 63 | /* Removed by https://bugs.openjdk.java.net/browse/JDK-8253119 */
|
67 | 64 | rerunClassInit(a, "java.net.SocketInputStream", "java.net.SocketOutputStream",
|
68 | 65 | /* Caches networking properties. */
|
69 | 66 | "java.net.DefaultDatagramSocketImplFactory");
|
70 |
| - } |
71 |
| - if (isWindows() && JavaVersionUtil.JAVA_SPEC < 19) { |
72 |
| - /* Removed by https://bugs.openjdk.java.net/browse/JDK-8253119 */ |
73 |
| - /* Caches networking properties. */ |
74 |
| - rerunClassInit(a, "java.net.PlainSocketImpl", "java.net.DualStackPlainDatagramSocketImpl", "java.net.TwoStacksPlainDatagramSocketImpl"); |
75 |
| - } else { |
76 |
| - assert isPosix() || JavaVersionUtil.JAVA_SPEC >= 19; |
77 |
| - if (JavaVersionUtil.JAVA_SPEC <= 17) { |
78 |
| - /* Removed by https://bugs.openjdk.java.net/browse/JDK-8253119 */ |
| 67 | + if (isWindows()) { |
| 68 | + /* Caches networking properties. */ |
| 69 | + rerunClassInit(a, "java.net.PlainSocketImpl", "java.net.DualStackPlainDatagramSocketImpl", "java.net.TwoStacksPlainDatagramSocketImpl"); |
| 70 | + } else { |
| 71 | + assert isPosix(); |
79 | 72 | rerunClassInit(a, "java.net.PlainDatagramSocketImpl", "java.net.PlainSocketImpl");
|
80 |
| - } |
81 |
| - if (hasExtendedOptionsImpl) { |
82 |
| - rerunClassInit(a, "sun.net.ExtendedOptionsImpl"); |
83 |
| - } |
84 |
| - |
85 |
| - if (JavaVersionUtil.JAVA_SPEC <= 17) { |
86 |
| - /* Removed by https://bugs.openjdk.java.net/browse/JDK-8253119 */ |
87 | 73 | rerunClassInit(a, "java.net.AbstractPlainDatagramSocketImpl", "java.net.AbstractPlainSocketImpl");
|
88 | 74 | }
|
| 75 | + } |
89 | 76 |
|
90 |
| - if (hasPlatformSocketOptions) { |
91 |
| - /* |
92 |
| - * The libextnet was actually introduced in Java 9, but the support for Linux, |
93 |
| - * Darwin and Windows was added later in Java 10, Java 11 and Java 19 respectively. |
94 |
| - */ |
95 |
| - rerunClassInit(a, "jdk.net.ExtendedSocketOptions", "jdk.net.ExtendedSocketOptions$PlatformSocketOptions"); |
96 |
| - /* |
97 |
| - * Different JDK versions are not consistent about the "ext" in the package name. We |
98 |
| - * need to support both variants. |
99 |
| - */ |
100 |
| - if (a.findClassByName("sun.net.ext.ExtendedSocketOptions") != null) { |
101 |
| - rerunClassInit(a, "sun.net.ext.ExtendedSocketOptions"); |
102 |
| - } else { |
103 |
| - rerunClassInit(a, "sun.net.ExtendedSocketOptions"); |
104 |
| - } |
105 |
| - } |
106 |
| - if (isDarwin()) { |
107 |
| - /* Caches the default interface. */ |
108 |
| - rerunClassInit(a, "java.net.DefaultInterface"); |
109 |
| - } |
| 77 | + if (this.hasPlatformSocketOptions && (isPosix() || JavaVersionUtil.JAVA_SPEC >= 19)) { |
| 78 | + /* |
| 79 | + * The libextnet was actually introduced in Java 9, but the support for Linux, Darwin |
| 80 | + * and Windows was added later in Java 10, Java 11 and Java 19 respectively. |
| 81 | + */ |
| 82 | + rerunClassInit(a, "jdk.net.ExtendedSocketOptions", "jdk.net.ExtendedSocketOptions$PlatformSocketOptions", "sun.net.ext.ExtendedSocketOptions"); |
| 83 | + } |
| 84 | + if (isDarwin()) { |
| 85 | + /* Caches the default interface. */ |
| 86 | + rerunClassInit(a, "java.net.DefaultInterface"); |
110 | 87 | }
|
111 | 88 | }
|
112 | 89 |
|
@@ -181,18 +158,10 @@ public void beforeAnalysis(BeforeAnalysisAccess a) {
|
181 | 158 | method(a, "java.net.PlainSocketImpl", "localAddress", int.class, clazz(a, "java.net.InetAddressContainer")));
|
182 | 159 | }
|
183 | 160 | }
|
184 |
| - if (isPosix()) { |
185 |
| - if (hasExtendedOptionsImpl) { |
186 |
| - a.registerReachabilityHandler(JNIRegistrationJavaNet::registerExtendedOptionsImplInit, |
187 |
| - method(a, "sun.net.ExtendedOptionsImpl", "init")); |
188 |
| - } |
189 |
| - } |
190 |
| - if (isPosix() || (isWindows() && JavaVersionUtil.JAVA_SPEC >= 19)) { |
191 |
| - if (hasPlatformSocketOptions) { |
192 |
| - /* Support for the libextnet. */ |
193 |
| - a.registerReachabilityHandler(JNIRegistrationJavaNet::registerPlatformSocketOptionsCreate, |
194 |
| - method(a, "jdk.net.ExtendedSocketOptions$PlatformSocketOptions", "create")); |
195 |
| - } |
| 161 | + if (this.hasPlatformSocketOptions && (isPosix() || JavaVersionUtil.JAVA_SPEC >= 19)) { |
| 162 | + /* Support for the libextnet. */ |
| 163 | + a.registerReachabilityHandler(JNIRegistrationJavaNet::registerPlatformSocketOptionsCreate, |
| 164 | + method(a, "jdk.net.ExtendedSocketOptions$PlatformSocketOptions", "create")); |
196 | 165 | }
|
197 | 166 |
|
198 | 167 | a.registerReachabilityHandler(JNIRegistrationJavaNet::registerDefaultProxySelectorInit, method(a, "sun.net.spi.DefaultProxySelector", "init"));
|
@@ -309,14 +278,6 @@ private static void registerDualStackPlainSocketImplLocalAddress(DuringAnalysisA
|
309 | 278 | RuntimeJNIAccess.register(fields(a, "java.net.InetAddressContainer", "addr"));
|
310 | 279 | }
|
311 | 280 |
|
312 |
| - private static void registerExtendedOptionsImplInit(DuringAnalysisAccess a) { |
313 |
| - RuntimeJNIAccess.register(clazz(a, "jdk.net.SocketFlow")); |
314 |
| - RuntimeJNIAccess.register(fields(a, "jdk.net.SocketFlow", "status", "priority", "bandwidth")); |
315 |
| - |
316 |
| - RuntimeJNIAccess.register(clazz(a, "jdk.net.SocketFlow$Status")); |
317 |
| - RuntimeJNIAccess.register(fields(a, "jdk.net.SocketFlow$Status", "NO_STATUS", "OK", "NO_PERMISSION", "NOT_CONNECTED", "NOT_SUPPORTED", "ALREADY_CREATED", "IN_PROGRESS", "OTHER")); |
318 |
| - } |
319 |
| - |
320 | 281 | private static void registerPlatformSocketOptionsCreate(DuringAnalysisAccess a) {
|
321 | 282 | String implClassName;
|
322 | 283 | if (isLinux()) {
|
|
0 commit comments