42
42
import static java .util .Arrays .asList ;
43
43
44
44
/**
45
- *
46
45
* @author Robert Scholte
47
46
* @since 3.0.0
48
47
*/
@@ -60,14 +59,12 @@ static URLClassLoaderBuilder builder() {
60
59
return new URLClassLoaderBuilder ();
61
60
}
62
61
63
- URLClassLoaderBuilder setExcludedJvmPackages (List <String > excludedJvmPackages )
64
- {
62
+ URLClassLoaderBuilder setExcludedJvmPackages (List <String > excludedJvmPackages ) {
65
63
this .excludedJvmPackages = excludedJvmPackages ;
66
64
return this ;
67
65
}
68
66
69
- URLClassLoaderBuilder setForcedJvmPackages (List <String > forcedJvmPackages )
70
- {
67
+ URLClassLoaderBuilder setForcedJvmPackages (List <String > forcedJvmPackages ) {
71
68
this .forcedJvmPackages = forcedJvmPackages ;
72
69
return this ;
73
70
}
@@ -110,7 +107,7 @@ URLClassLoader build() throws IOException {
110
107
}
111
108
}
112
109
113
- return new ExecJavaClassLoader ( urls .toArray ( new URL [0 ] ), transformer , logger , forcedJvmPackages , excludedJvmPackages );
110
+ return new ExecJavaClassLoader (urls .toArray (new URL [0 ]), transformer , forcedJvmPackages , excludedJvmPackages );
114
111
}
115
112
116
113
// child first strategy
@@ -124,16 +121,17 @@ private static class ExecJavaClassLoader extends URLClassLoader {
124
121
}
125
122
126
123
private final String jre ;
127
- private final Log logger ;
128
124
private final ClassFileTransformer transformer ;
129
125
private final List <String > forcedJvmPackages ;
130
126
private final List <String > excludedJvmPackages ;
131
127
132
- public ExecJavaClassLoader (URL [] urls , ClassFileTransformer transformer , Log logger , List <String > forcedJvmPackages , List <String > excludedJvmPackages )
133
- {
128
+ public ExecJavaClassLoader (
129
+ URL [] urls ,
130
+ ClassFileTransformer transformer ,
131
+ List <String > forcedJvmPackages ,
132
+ List <String > excludedJvmPackages ) {
134
133
super (urls );
135
134
this .jre = getJre ();
136
- this .logger = logger ;
137
135
this .transformer = transformer ;
138
136
this .forcedJvmPackages = forcedJvmPackages ;
139
137
this .excludedJvmPackages = excludedJvmPackages ;
@@ -328,151 +326,104 @@ private boolean postLoad(boolean resolve, Class<?> clazz) {
328
326
329
327
// not all jvm classes, for ex "javax" can be overridden so don't list it them all here (javax.resource for ex)
330
328
private boolean isDirectJvmClass (final String name ) {
331
- if (excludedJvmPackages != null && excludedJvmPackages .stream ().anyMatch ( name ::startsWith ))
332
- {
329
+ if (excludedJvmPackages != null && excludedJvmPackages .stream ().anyMatch (name ::startsWith )) {
333
330
return false ;
334
331
}
335
- if (name .startsWith ( "java." ) )
336
- {
332
+ if (name .startsWith ("java." )) {
337
333
return true ;
338
- }
339
- if ( name .startsWith ( "sun." ) )
340
- {
334
+ } else if (name .startsWith ("javax." )) {
335
+ final String sub = name .substring ("javax." .length ());
336
+ if (sub .startsWith ("xml." )) {
337
+ return true ;
338
+ }
339
+ } else if (name .startsWith ("sun." )) {
341
340
return true ;
342
- }
343
- if ( name .startsWith ( "jdk." ) )
344
- {
341
+ } else if (name .startsWith ("jdk." )) {
345
342
return true ;
346
- }
347
- if ( name .startsWith ( "oracle." ) )
348
- {
343
+ } else if (name .startsWith ("oracle." )) {
349
344
return true ;
350
- }
351
- if ( name .startsWith ( "javafx." ) )
352
- {
345
+ } else if (name .startsWith ("javafx." )) {
353
346
return true ;
354
- }
355
- if ( name .startsWith ( "netscape." ) )
356
- {
347
+ } else if (name .startsWith ("netscape." )) {
357
348
return true ;
358
- }
359
- if ( name .startsWith ( "org." ) )
360
- {
361
- final String sub = name .substring ( "org." .length () );
362
- if ( sub .startsWith ( "w3c.dom." ) )
363
- {
349
+ } else if (name .startsWith ("org." )) {
350
+ final String sub = name .substring ("org." .length ());
351
+ if (sub .startsWith ("w3c.dom." )) {
364
352
return true ;
365
- }
366
- if ( sub .startsWith ( "omg." ) )
367
- {
353
+ } else if (sub .startsWith ("omg." )) {
368
354
return true ;
369
- }
370
- if ( sub .startsWith ( "xml.sax." ) )
371
- {
355
+ } else if (sub .startsWith ("xml.sax." )) {
372
356
return true ;
373
- }
374
- if ( sub .startsWith ( "ietf.jgss." ) )
375
- {
357
+ } else if (sub .startsWith ("ietf.jgss." )) {
376
358
return true ;
377
- }
378
- if ( sub .startsWith ( "jcp.xml.dsig.internal." ) )
379
- {
359
+ } else if (sub .startsWith ("jcp.xml.dsig.internal." )) {
380
360
return true ;
381
361
}
382
- }
383
- if ( name .startsWith ( "com." ) )
384
- {
385
- final String sub = name .substring ( "com." .length () );
386
- if ( sub .startsWith ( "oracle." ) )
387
- {
362
+ } else if (name .startsWith ("com." )) {
363
+ final String sub = name .substring ("com." .length ());
364
+ if (sub .startsWith ("oracle." )) {
388
365
return true ;
389
- }
390
- if ( sub .startsWith ( "sun." ) )
391
- {
392
- final String subSun = sub .substring ( "sun." .length () );
393
- if ( subSun .startsWith ( "accessibility." ) )
394
- {
366
+ } else if (sub .startsWith ("sun." )) {
367
+ final String subSun = sub .substring ("sun." .length ());
368
+ if (subSun .startsWith ("accessibility." )) {
395
369
return true ;
396
- }
397
- if (subSun .startsWith ("activation." )) {
370
+ } else if (subSun .startsWith ("activation." )) {
398
371
return true ;
399
- }
400
- if (subSun .startsWith ("awt." )) {
372
+ } else if (subSun .startsWith ("awt." )) {
401
373
return true ;
402
- }
403
- if (subSun .startsWith ("beans." )) {
374
+ } else if (subSun .startsWith ("beans." )) {
404
375
return true ;
405
- }
406
- if (subSun .startsWith ("corba.se." )) {
376
+ } else if (subSun .startsWith ("corba.se." )) {
407
377
return true ;
408
- }
409
- if (subSun .startsWith ("demo.jvmti." )) {
378
+ } else if (subSun .startsWith ("demo.jvmti." )) {
410
379
return true ;
411
- }
412
- if (subSun .startsWith ("image.codec.jpeg." )) {
380
+ } else if (subSun .startsWith ("image.codec.jpeg." )) {
413
381
return true ;
414
- }
415
- if (subSun .startsWith ("imageio." )) {
382
+ } else if (subSun .startsWith ("imageio." )) {
416
383
return true ;
417
- }
418
- if (subSun .startsWith ("istack.internal." )) {
384
+ } else if (subSun .startsWith ("istack.internal." )) {
419
385
return true ;
420
- }
421
- if (subSun .startsWith ("java." )) {
386
+ } else if (subSun .startsWith ("java." )) {
422
387
return true ;
423
- }
424
- if (subSun .startsWith ("java_cup." )) {
388
+ } else if (subSun .startsWith ("java_cup." )) {
425
389
return true ;
426
- }
427
- if (subSun .startsWith ("jmx." )) {
390
+ } else if (subSun .startsWith ("jmx." )) {
428
391
return true ;
429
- }
430
- if (subSun .startsWith ("jndi." )) {
392
+ } else if (subSun .startsWith ("jndi." )) {
431
393
return true ;
432
- }
433
- if (subSun .startsWith ("management." )) {
394
+ } else if (subSun .startsWith ("management." )) {
434
395
return true ;
435
- }
436
- if (subSun .startsWith ("media.sound." )) {
396
+ } else if (subSun .startsWith ("media.sound." )) {
437
397
return true ;
438
- }
439
- if (subSun .startsWith ("naming.internal." )) {
398
+ } else if (subSun .startsWith ("naming.internal." )) {
440
399
return true ;
441
- }
442
- if (subSun .startsWith ("net." )) {
400
+ } else if (subSun .startsWith ("net." )) {
443
401
return true ;
444
- }
445
- if (subSun .startsWith ("nio." )) {
402
+ } else if (subSun .startsWith ("nio." )) {
446
403
return true ;
447
- }
448
- if (subSun .startsWith ("org." )) {
404
+ } else if (subSun .startsWith ("org." )) {
449
405
return true ;
450
- }
451
- if (subSun .startsWith ("rmi.rmid." )) {
406
+ } else if (subSun .startsWith ("rmi.rmid." )) {
452
407
return true ;
453
- }
454
- if (subSun .startsWith ("rowset." )) {
408
+ } else if (subSun .startsWith ("rowset." )) {
455
409
return true ;
456
- }
457
- if (subSun .startsWith ("security." )) {
410
+ } else if (subSun .startsWith ("security." )) {
458
411
return true ;
459
- }
460
- if (subSun .startsWith ("swing." )) {
412
+ } else if (subSun .startsWith ("swing." )) {
461
413
return true ;
462
- }
463
- if (subSun .startsWith ("tracing." )) {
414
+ } else if (subSun .startsWith ("tracing." )) {
464
415
return true ;
465
- }
466
- if (subSun .startsWith ("xml.internal." )) {
416
+ } else if (subSun .startsWith ("xml.internal." )) {
467
417
return true ;
468
418
}
469
419
}
470
420
}
471
- return forcedJvmPackages != null && forcedJvmPackages .stream ().anyMatch ( name ::startsWith );
421
+ return forcedJvmPackages != null && forcedJvmPackages .stream ().anyMatch (name ::startsWith );
472
422
}
473
423
474
424
private class FilteringUrlEnum implements Enumeration <URL > {
475
425
private final Enumeration <URL > delegate ;
426
+
476
427
private URL next ;
477
428
478
429
private FilteringUrlEnum (Enumeration <URL > delegate ) {
@@ -498,6 +449,7 @@ public URL nextElement() {
498
449
499
450
private static class ChainedEnumerations implements Enumeration <URL > {
500
451
private final Iterator <Enumeration <URL >> enumerations ;
452
+
501
453
private Enumeration <URL > current ;
502
454
503
455
private ChainedEnumerations (Iterator <Enumeration <URL >> enumerations ) {
0 commit comments