private static void scanJar(File file, ClassLoader classloader, Set<URI> scannedUris, Visitor visitor) throws IOException {
JarFile jarFile;
try {
jarFile = new JarFile(file);
} catch (IOException e) {
return;
}
try {
for (URI uri : getClassPathFromManifest(file, jarFile.getManifest()))
scan(uri, classloader, scannedUris, visitor);
for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
JarEntry entry = entries.nextElement();
if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME))
continue;
try {
visitor.visit(entry.getName(), new URL("jar:file:" + file.getCanonicalPath() + "!/" + entry.getName()), classloader);
} catch (IOException e) {
throw new IOException("Exception thrown during scanning of jar file " + file + " entry " + entry, e);
} catch (RuntimeException e) {
throw new RuntimeException("Exception thrown during scanning of jar file " + file + " entry " + entry, e);
}
}
} finally {
try {
jarFile.close();
} catch (IOException ignored) {
}
}
}