Skip to content
New issue

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

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

Already on GitHub? # to your account

CtExecutableReferenceImpl may throw a NullPointerException in getDeclaration #808

Closed
msteinbeck opened this issue Aug 30, 2016 · 1 comment

Comments

@msteinbeck
Copy link
Contributor

msteinbeck commented Aug 30, 2016

I found that CtExecutableReferenceImpl#getDeclaration may throw a NullPointerException in noclasspath mode. Unfortunately, I can not provide a short example but it definitely occurs. The following snippet shows it's implementation:

@Override
@SuppressWarnings("unchecked")
public CtExecutable<T> getDeclaration() {
    return getCtExecutable(getDeclaringType().getDeclaration());
}

As we can see, getDeclaration calls getDeclaringType() which, according to it's JavaDoc, may return null. By calling getDeclaringType().getDeclaration() a NullPointerException is throws if getDeclaringType() is null.

msteinbeck added a commit to msteinbeck/spoon that referenced this issue Aug 30, 2016
According to JavaDoc, `getDeclaringType()` may return null. Until now,
`getDeclaration`, does not handle the null case and, therefore, may
throw a NullPointerException. This exception is throws most likely in
noclasspath mode.  Fixes INRIA#808.
@msteinbeck
Copy link
Contributor Author

An example is given in PR.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant