4242import static java .util .Arrays .asList ;
4343
4444/**
45- *
4645 * @author Robert Scholte
4746 * @since 3.0.0
4847 */
@@ -60,14 +59,12 @@ static URLClassLoaderBuilder builder() {
6059 return new URLClassLoaderBuilder ();
6160 }
6261
63- URLClassLoaderBuilder setExcludedJvmPackages (List <String > excludedJvmPackages )
64- {
62+ URLClassLoaderBuilder setExcludedJvmPackages (List <String > excludedJvmPackages ) {
6563 this .excludedJvmPackages = excludedJvmPackages ;
6664 return this ;
6765 }
6866
69- URLClassLoaderBuilder setForcedJvmPackages (List <String > forcedJvmPackages )
70- {
67+ URLClassLoaderBuilder setForcedJvmPackages (List <String > forcedJvmPackages ) {
7168 this .forcedJvmPackages = forcedJvmPackages ;
7269 return this ;
7370 }
@@ -110,7 +107,8 @@ URLClassLoader build() throws IOException {
110107 }
111108 }
112109
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 );
114112 }
115113
116114 // child first strategy
@@ -124,16 +122,17 @@ private static class ExecJavaClassLoader extends URLClassLoader {
124122 }
125123
126124 private final String jre ;
127- private final Log logger ;
128125 private final ClassFileTransformer transformer ;
129126 private final List <String > forcedJvmPackages ;
130127 private final List <String > excludedJvmPackages ;
131128
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 ) {
134134 super (urls );
135135 this .jre = getJre ();
136- this .logger = logger ;
137136 this .transformer = transformer ;
138137 this .forcedJvmPackages = forcedJvmPackages ;
139138 this .excludedJvmPackages = excludedJvmPackages ;
@@ -328,151 +327,104 @@ private boolean postLoad(boolean resolve, Class<?> clazz) {
328327
329328 // not all jvm classes, for ex "javax" can be overridden so don't list it them all here (javax.resource for ex)
330329 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 )) {
333331 return false ;
334332 }
335- if (name .startsWith ( "java." ) )
336- {
333+ if (name .startsWith ("java." )) {
337334 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." )) {
341341 return true ;
342- }
343- if ( name .startsWith ( "jdk." ) )
344- {
342+ } else if (name .startsWith ("jdk." )) {
345343 return true ;
346- }
347- if ( name .startsWith ( "oracle." ) )
348- {
344+ } else if (name .startsWith ("oracle." )) {
349345 return true ;
350- }
351- if ( name .startsWith ( "javafx." ) )
352- {
346+ } else if (name .startsWith ("javafx." )) {
353347 return true ;
354- }
355- if ( name .startsWith ( "netscape." ) )
356- {
348+ } else if (name .startsWith ("netscape." )) {
357349 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." )) {
364353 return true ;
365- }
366- if ( sub .startsWith ( "omg." ) )
367- {
354+ } else if (sub .startsWith ("omg." )) {
368355 return true ;
369- }
370- if ( sub .startsWith ( "xml.sax." ) )
371- {
356+ } else if (sub .startsWith ("xml.sax." )) {
372357 return true ;
373- }
374- if ( sub .startsWith ( "ietf.jgss." ) )
375- {
358+ } else if (sub .startsWith ("ietf.jgss." )) {
376359 return true ;
377- }
378- if ( sub .startsWith ( "jcp.xml.dsig.internal." ) )
379- {
360+ } else if (sub .startsWith ("jcp.xml.dsig.internal." )) {
380361 return true ;
381362 }
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." )) {
388366 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." )) {
395370 return true ;
396- }
397- if (subSun .startsWith ("activation." )) {
371+ } else if (subSun .startsWith ("activation." )) {
398372 return true ;
399- }
400- if (subSun .startsWith ("awt." )) {
373+ } else if (subSun .startsWith ("awt." )) {
401374 return true ;
402- }
403- if (subSun .startsWith ("beans." )) {
375+ } else if (subSun .startsWith ("beans." )) {
404376 return true ;
405- }
406- if (subSun .startsWith ("corba.se." )) {
377+ } else if (subSun .startsWith ("corba.se." )) {
407378 return true ;
408- }
409- if (subSun .startsWith ("demo.jvmti." )) {
379+ } else if (subSun .startsWith ("demo.jvmti." )) {
410380 return true ;
411- }
412- if (subSun .startsWith ("image.codec.jpeg." )) {
381+ } else if (subSun .startsWith ("image.codec.jpeg." )) {
413382 return true ;
414- }
415- if (subSun .startsWith ("imageio." )) {
383+ } else if (subSun .startsWith ("imageio." )) {
416384 return true ;
417- }
418- if (subSun .startsWith ("istack.internal." )) {
385+ } else if (subSun .startsWith ("istack.internal." )) {
419386 return true ;
420- }
421- if (subSun .startsWith ("java." )) {
387+ } else if (subSun .startsWith ("java." )) {
422388 return true ;
423- }
424- if (subSun .startsWith ("java_cup." )) {
389+ } else if (subSun .startsWith ("java_cup." )) {
425390 return true ;
426- }
427- if (subSun .startsWith ("jmx." )) {
391+ } else if (subSun .startsWith ("jmx." )) {
428392 return true ;
429- }
430- if (subSun .startsWith ("jndi." )) {
393+ } else if (subSun .startsWith ("jndi." )) {
431394 return true ;
432- }
433- if (subSun .startsWith ("management." )) {
395+ } else if (subSun .startsWith ("management." )) {
434396 return true ;
435- }
436- if (subSun .startsWith ("media.sound." )) {
397+ } else if (subSun .startsWith ("media.sound." )) {
437398 return true ;
438- }
439- if (subSun .startsWith ("naming.internal." )) {
399+ } else if (subSun .startsWith ("naming.internal." )) {
440400 return true ;
441- }
442- if (subSun .startsWith ("net." )) {
401+ } else if (subSun .startsWith ("net." )) {
443402 return true ;
444- }
445- if (subSun .startsWith ("nio." )) {
403+ } else if (subSun .startsWith ("nio." )) {
446404 return true ;
447- }
448- if (subSun .startsWith ("org." )) {
405+ } else if (subSun .startsWith ("org." )) {
449406 return true ;
450- }
451- if (subSun .startsWith ("rmi.rmid." )) {
407+ } else if (subSun .startsWith ("rmi.rmid." )) {
452408 return true ;
453- }
454- if (subSun .startsWith ("rowset." )) {
409+ } else if (subSun .startsWith ("rowset." )) {
455410 return true ;
456- }
457- if (subSun .startsWith ("security." )) {
411+ } else if (subSun .startsWith ("security." )) {
458412 return true ;
459- }
460- if (subSun .startsWith ("swing." )) {
413+ } else if (subSun .startsWith ("swing." )) {
461414 return true ;
462- }
463- if (subSun .startsWith ("tracing." )) {
415+ } else if (subSun .startsWith ("tracing." )) {
464416 return true ;
465- }
466- if (subSun .startsWith ("xml.internal." )) {
417+ } else if (subSun .startsWith ("xml.internal." )) {
467418 return true ;
468419 }
469420 }
470421 }
471- return forcedJvmPackages != null && forcedJvmPackages .stream ().anyMatch ( name ::startsWith );
422+ return forcedJvmPackages != null && forcedJvmPackages .stream ().anyMatch (name ::startsWith );
472423 }
473424
474425 private class FilteringUrlEnum implements Enumeration <URL > {
475426 private final Enumeration <URL > delegate ;
427+
476428 private URL next ;
477429
478430 private FilteringUrlEnum (Enumeration <URL > delegate ) {
@@ -498,6 +450,7 @@ public URL nextElement() {
498450
499451 private static class ChainedEnumerations implements Enumeration <URL > {
500452 private final Iterator <Enumeration <URL >> enumerations ;
453+
501454 private Enumeration <URL > current ;
502455
503456 private ChainedEnumerations (Iterator <Enumeration <URL >> enumerations ) {
0 commit comments