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

fix NPE with duplicate inner class #2972

Merged
merged 2 commits into from
May 27, 2019
Merged

fix NPE with duplicate inner class #2972

merged 2 commits into from
May 27, 2019

Conversation

Charmik
Copy link
Contributor

@Charmik Charmik commented May 12, 2019

This code is decompilation of the bytecode file, but as I understand parser should never throw exception when it tries to build AST. I would prefer if it would just skip the second class, if it's possible. Or maybe you prefer another way for it? Thanks.

stacktrace:
java.lang.NullPointerException
at spoon.support.compiler.jdt.JDTTreeBuilderHelper.createType(JDTTreeBuilderHelper.java:623)
at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:1663)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1485)

@monperrus
Copy link
Collaborator

I reproduced the NPE, thanks for the failing test case, it's very valuable.

Looking at it.

@monperrus monperrus changed the title add test which produces NPE with duplicate class fix NPE with duplicate inner class May 26, 2019
@monperrus
Copy link
Collaborator

The fix was easy: protect against null.

JDT is very inconsistent, and in some cases, some fields are null. Since we have no control over this, JDTTreeBuilder is full of defensive checks.

@Charmik
Copy link
Contributor Author

Charmik commented May 26, 2019

The fix was easy: protect against null.

JDT is very inconsistent, and in some cases, some fields are null. Since we have no control over this, JDTTreeBuilder is full of defensive checks.

nice! thanks!
can I ask why you don't create PR in JDT? because it takes too much time?:)

@nharrand nharrand merged commit 975a348 into INRIA:master May 27, 2019
@nharrand
Copy link
Collaborator

Thanks a lot for the contribution!

@monperrus monperrus mentioned this pull request Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants