Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialization of ClassPath ends with NullPointerException #2239

Closed
display-none opened this issue Nov 30, 2015 · 2 comments
Closed

Initialization of ClassPath ends with NullPointerException #2239

display-none opened this issue Nov 30, 2015 · 2 comments

Comments

@display-none
Copy link

An attempt to call com.google.common.reflect.ClassPath#from ends with NullPointerException on IBM WebSphere 8.5.5.5. The following snippet from com.google.common.reflect.ClassPath#getClassPathEntries causes issues:

URLClassLoader urlClassLoader = (URLClassLoader) classloader;
for (URL entry : urlClassLoader.getURLs()) {

getURLs() on com.ibm.ws.bootstrap.ExtClassLoader returns null:

    public URL[] getURLs() {
        return null;
    }

    public URL[] _getURLs() {
        return super.getURLs();
    }

It looks like IBM made this on purpose, so I guess reporting to Guava is more appropriate here.

@lowasser
Copy link
Contributor

Is that a spec-compliant implementation? https://docs.oracle.com/javase/7/docs/api/java/net/URLClassLoader.html#getURLs() doesn't seem to suggest the possibility of returning null there.

@kluever
Copy link
Member

kluever commented Jan 14, 2016

As Louis points out, URLClassLoader.getURLs() doesn't say anything about returning null. Since _getURLs() isn't part of the public URLClassLoader API, we couldn't call it anyways.

Please open a bug against IBM WebSphere.

@kluever kluever closed this as completed Jan 14, 2016
finaglehelper pushed a commit to twitter/util that referenced this issue Jun 12, 2018
Summary: Problem/Solution

We cannot rely on `URLClassLoader#getURLs` to not return a null instance.
Update the code to protect against this possibility.

See: google/guava#2239

Fixes issue #695.

JIRA Issues: CSL-6530

Differential Revision: https://phabricator.twitter.biz/D181152
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants