Hi,
I'm really impressed by classgraph - classloading is tricky, and I'm glad to see a library like this make it easier :).
Is accessing a single non-class resource via classgraph an intended use-case? It's clearly possible, but I'm finding that it is about an order of magnitude slower than loading directly from a ClassLoader (on a variety of classpath sizes), and startup speed is in an important concern for my current situation. I've tried a variety of whitelisting, and disabling different types of scanning, but I'm not seeing the speed that I'm hoping to achieve.
private void processResourceClassloader(ClassLoader loader, String name) throws IOException {
final Enumeration<URL> urls = loader.getResources(name);
while (urls.hasMoreElements()) {
final URL url = urls.nextElement();
try (final InputStream in = url.openStream()) {
doFastOperation(in);
}
}
}
private void processResourceClassgraph(ClassLoader loader, String name) throws IOException {
try (final ScanResult scan = new ClassGraph()
.overrideClassLoaders(loader)
.disableNestedJarScanning()
.disableModuleScanning()
.whitelistClasspathElementsContainingResourcePath(name)
//.whitelistPaths(name)
.scan()) {
for (final Resource resource : scan.getResourcesWithPath(name)) {
try (final InputStream in = resource.open()) {
doFastOperation(in);
}
}
}
}
Hi,
I'm really impressed by classgraph - classloading is tricky, and I'm glad to see a library like this make it easier :).
Is accessing a single non-class resource via classgraph an intended use-case? It's clearly possible, but I'm finding that it is about an order of magnitude slower than loading directly from a
ClassLoader(on a variety of classpath sizes), and startup speed is in an important concern for my current situation. I've tried a variety of whitelisting, and disabling different types of scanning, but I'm not seeing the speed that I'm hoping to achieve.