@@ -132,7 +132,6 @@ public void run() {
132
132
FileInputStream .class ,
133
133
FileOutputStream .class ,
134
134
RandomAccessFile .class ,
135
- Class .forName ("java.net.PlainSocketImpl" ),
136
135
ZipFile .class ,
137
136
AbstractSelectableChannel .class ,
138
137
AbstractInterruptibleChannel .class ,
@@ -142,6 +141,7 @@ public void run() {
142
141
143
142
addIfFound (classes , "sun.nio.ch.SocketChannelImpl" );
144
143
addIfFound (classes , "java.net.AbstractPlainSocketImpl" );
144
+ addIfFound (classes , "java.net.PlainSocketImpl" );
145
145
addIfFound (classes , "sun.nio.fs.UnixDirectoryStream" );
146
146
addIfFound (classes , "sun.nio.fs.UnixSecureDirectoryStream" );
147
147
addIfFound (classes , "sun.nio.fs.WindowsDirectoryStream" );
@@ -301,59 +301,59 @@ static List<ClassTransformSpec> createSpec() {
301
301
new ClassTransformSpec (
302
302
"sun/nio/fs/WindowsDirectoryStream" , new CloseInterceptor ("close" )));
303
303
}
304
- Collections .addAll (
305
- spec ,
306
- /*
307
- * Detect selectors, which may open native pipes and anonymous inodes for event polling.
308
- */
309
- new ClassTransformSpec (AbstractSelector .class ,
310
- new ConstructorInterceptor ("(Ljava/nio/channels/spi/SelectorProvider;)V" , "openSelector" ),
311
- new CloseInterceptor ("close" )),
304
+ /*
305
+ * Detect selectors, which may open native pipes and anonymous inodes for event polling.
306
+ */
307
+ spec .add (new ClassTransformSpec (
308
+ AbstractSelector .class ,
309
+ new ConstructorInterceptor ("(Ljava/nio/channels/spi/SelectorProvider;)V" , "openSelector" ),
310
+ new CloseInterceptor ("close" )));
311
+ /*
312
+ * java.net.Socket/ServerSocket uses SocketImpl, and this is where FileDescriptors are actually managed.
313
+ *
314
+ * SocketInputStream/SocketOutputStream does not maintain a separate FileDescriptor. They just all piggy back on
315
+ * the same SocketImpl instance.
316
+ */
317
+ if (Runtime .version ().feature () < 19 ) {
318
+ spec .add (new ClassTransformSpec (
319
+ "java/net/PlainSocketImpl" ,
320
+ // this is where a new file descriptor is allocated.
321
+ // it'll occupy a socket even before it gets connected
322
+ new OpenSocketInterceptor ("create" , "(Z)V" ),
312
323
313
- /*
314
- java.net.Socket/ServerSocket uses SocketImpl, and this is where FileDescriptors
315
- are actually managed.
324
+ // When a socket is accepted, it goes to "accept(SocketImpl s)"
325
+ // where 's' is the new socket and ' this' is the server socket
326
+ new AcceptInterceptor ( "accept" , "(Ljava/net/SocketImpl;)V" ),
316
327
317
- SocketInputStream/SocketOutputStream does not maintain a separate FileDescriptor.
318
- They just all piggy back on the same SocketImpl instance.
319
- */
320
- new ClassTransformSpec ("java/net/PlainSocketImpl" ,
328
+ // file descriptor actually get closed in socketClose()
329
+ // socketPreClose() appears to do something similar, but if you read the source code
330
+ // of the native socketClose0() method, then you see that it actually doesn't close
331
+ // a file descriptor.
332
+ new CloseInterceptor ("socketClose" )));
333
+ // Later versions of the JDK abstracted out the parts of PlainSocketImpl above into a super class
334
+ spec .add (new ClassTransformSpec (
335
+ "java/net/AbstractPlainSocketImpl" ,
321
336
// this is where a new file descriptor is allocated.
322
337
// it'll occupy a socket even before it gets connected
323
338
new OpenSocketInterceptor ("create" , "(Z)V" ),
324
339
325
340
// When a socket is accepted, it goes to "accept(SocketImpl s)"
326
341
// where 's' is the new socket and 'this' is the server socket
327
- new AcceptInterceptor ("accept" ,"(Ljava/net/SocketImpl;)V" ),
342
+ new AcceptInterceptor ("accept" , "(Ljava/net/SocketImpl;)V" ),
328
343
329
344
// file descriptor actually get closed in socketClose()
330
345
// socketPreClose() appears to do something similar, but if you read the source code
331
346
// of the native socketClose0() method, then you see that it actually doesn't close
332
347
// a file descriptor.
333
- new CloseInterceptor ("socketClose" )
334
- ),
335
- // Later versions of the JDK abstracted out the parts of PlainSocketImpl above into a super class
336
- new ClassTransformSpec ("java/net/AbstractPlainSocketImpl" ,
337
- // this is where a new file descriptor is allocated.
338
- // it'll occupy a socket even before it gets connected
339
- new OpenSocketInterceptor ("create" , "(Z)V" ),
340
-
341
- // When a socket is accepted, it goes to "accept(SocketImpl s)"
342
- // where 's' is the new socket and 'this' is the server socket
343
- new AcceptInterceptor ("accept" ,"(Ljava/net/SocketImpl;)V" ),
344
-
345
- // file descriptor actually get closed in socketClose()
346
- // socketPreClose() appears to do something similar, but if you read the source code
347
- // of the native socketClose0() method, then you see that it actually doesn't close
348
- // a file descriptor.
349
- new CloseInterceptor ("socketClose" )
350
- ),
351
- new ClassTransformSpec ("sun/nio/ch/SocketChannelImpl" ,
352
- new OpenSocketInterceptor ("<init>" , "(Ljava/nio/channels/spi/SelectorProvider;Ljava/io/FileDescriptor;Ljava/net/InetSocketAddress;)V" ),
353
- new OpenSocketInterceptor ("<init>" , "(Ljava/nio/channels/spi/SelectorProvider;)V" ),
354
- new CloseInterceptor ("kill" )
355
- )
356
- );
348
+ new CloseInterceptor ("socketClose" )));
349
+ }
350
+ spec .add (new ClassTransformSpec (
351
+ "sun/nio/ch/SocketChannelImpl" ,
352
+ new OpenSocketInterceptor (
353
+ "<init>" ,
354
+ "(Ljava/nio/channels/spi/SelectorProvider;Ljava/io/FileDescriptor;Ljava/net/InetSocketAddress;)V" ),
355
+ new OpenSocketInterceptor ("<init>" , "(Ljava/nio/channels/spi/SelectorProvider;)V" ),
356
+ new CloseInterceptor ("kill" )));
357
357
return spec ;
358
358
}
359
359
0 commit comments