/** * Returns a {@link ClassPath} instance that represents the classpath that the given class is loaded from the given * ClassLoader. */ private static ClassPath getClassPath(ClassLoader classLoader, Class<?> cls) throws IOException { String resourceName = cls.getName().replace('.', '/') + ".class"; URL url = classLoader.getResource(resourceName); if (url == null) { throw new IOException("Resource not found for " + resourceName); } try { URI classPathURI = getClassPathURL(resourceName, url).toURI(); return ClassPath.from(classPathURI, classLoader); } catch (URISyntaxException e) { throw new IOException(e); } }
/** * Returns a {@link ClassPath} instance that represents the classpath that the given class is loaded from the given * ClassLoader. */ private static ClassPath getClassPath(ClassLoader classLoader, Class<?> cls) throws IOException { String resourceName = cls.getName().replace('.', '/') + ".class"; URL url = classLoader.getResource(resourceName); if (url == null) { throw new IOException("Resource not found for " + resourceName); } try { URI classPathURI = getClassPathURL(resourceName, url).toURI(); return ClassPath.from(classPathURI, classLoader); } catch (URISyntaxException e) { throw new IOException(e); } }