11package org .testng .internal ;
22
3+ import static java .nio .charset .StandardCharsets .UTF_8 ;
4+
35import java .io .File ;
46import java .io .IOException ;
5- import java .io .UnsupportedEncodingException ;
67import java .lang .reflect .Method ;
78import java .net .JarURLConnection ;
89import java .net .URL ;
2526 * @author <a href="mailto:[email protected] ">Cedric Beust</a> 2627 */
2728public class PackageUtils {
28- private static final String UTF_8 = "UTF-8" ;
2929 private static final String PACKAGE_UTILS = PackageUtils .class .getSimpleName ();
3030 private static String [] testClassPaths ;
3131
@@ -36,11 +36,6 @@ private PackageUtils() {
3636 // Utility class. Defeat instantiation.
3737 }
3838
39- /** Add a class loader to the searchable loaders. */
40- public static void addClassLoader (final ClassLoader loader ) {
41- classLoaders .add (loader );
42- }
43-
4439 /**
4540 * @param packageName - The package name
4641 * @param included - The inclusion list.
@@ -96,6 +91,9 @@ public static String[] findClassesInPackage(
9691 while (entries .hasMoreElements ()) {
9792 JarEntry entry = entries .nextElement ();
9893 String name = entry .getName ();
94+ if (name .startsWith ("module-info" ) || name .startsWith ("META-INF" )) {
95+ continue ;
96+ }
9997 if (name .charAt (0 ) == '/' ) {
10098 name = name .substring (1 );
10199 }
@@ -183,11 +181,7 @@ private static boolean matchTestClasspath(URL url, String lastFragment, boolean
183181 }
184182
185183 String fileName = "" ;
186- try {
187- fileName = URLDecoder .decode (url .getFile (), UTF_8 );
188- } catch (UnsupportedEncodingException ueex ) {
189- // ignore. should never happen
190- }
184+ fileName = URLDecoder .decode (url .getFile (), UTF_8 );
191185
192186 for (String classpathFrag : classpathFragments ) {
193187 String path = classpathFrag + lastFragment ;
0 commit comments