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

CtElementImpl#hasParent(CtElement) may throw a NullPointerException #679

Closed
msteinbeck opened this issue May 27, 2016 · 0 comments
Closed

Comments

@msteinbeck
Copy link
Contributor

You will find the following line in hasParent of CtElementImpl:

return getParent() == candidate || getParent().hasParent(candidate);

This assumes, that getParent may not return null. However, in line 50 of CtModelImpl null is explicitly returned:

{
    this.setSimpleName(CtPackage.TOP_LEVEL_PACKAGE_NAME);
    this.setParent(new CtElementImpl() {
        @Override
    public void accept(CtVisitor visitor) {

    }

        @Override
    public CtElement getParent() throws ParentNotInitializedException {
        return null;
    }
    });
}

I got some cases (unfortunately they are to large to post here) in which this results to a NullPointerException.

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

No branches or pull requests

1 participant