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