In our Envirenment (Websphere 7) occurs a Nullpointer in
getUrlsForCurrentClasspath() in the ClasspathHelper.
I don't know why but the Method getUrls() on the URLClassLoader returns
sometimes null and so on the Collections.addAll method can not handle such a
Null Value.
I am using the latest reflections-0.9.5-RC2.jar
I have modified the Method to prevent a NullPointer
public static Set<URL> getUrlsForCurrentClasspath() {
Set<URL> urls = Sets.newHashSet();
//is URLClassLoader?
ClassLoader loader = Utils.getContextClassLoader();
while (loader != null) {
if (loader instanceof URLClassLoader) {
URL[] theUrls = ((URLClassLoader) loader).getURLs();
if (theUrls != null)
Collections.addAll(urls, theUrls);
}
loader = loader.getParent();
}
if (urls.isEmpty()) {
//get from java.class.path
String javaClassPath = System.getProperty("java.class.path");
if (javaClassPath != null) {
for (String path : javaClassPath.split(File.pathSeparator)) {
try {
urls.add(new File(path).toURI().toURL());
} catch (Exception e) {
throw new ReflectionsException("could not create url from " + path, e);
}
}
}
}
return ImmutableSet.copyOf(urls);
}
Original issue reported on code.google.com by c.ko...@gmail.com on 18 Nov 2010 at 9:17
Original issue reported on code.google.com by
c.ko...@gmail.com
on 18 Nov 2010 at 9:17