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

Bug: Exception in thread "main" java.lang.NullPointerException: Cannot read field "compoundName" because "memberType.binding" is null #3950

Closed
djaekim opened this issue May 25, 2021 · 4 comments · Fixed by #3961
Assignees
Labels

Comments

@djaekim
Copy link

djaekim commented May 25, 2021

Exception in thread "main" java.lang.NullPointerException: Cannot read field "compoundName" because "memberType.binding" is null
	at spoon.support.compiler.jdt.JDTTreeBuilderQuery.searchTypeBinding(JDTTreeBuilderQuery.java:84)
	at spoon.support.compiler.jdt.ReferenceBuilder.getQualifiedTypeReference(ReferenceBuilder.java:285)
	at spoon.support.compiler.jdt.JDTTreeBuilderHelper.createTypeAccess(JDTTreeBuilderHelper.java:445)
	at spoon.support.compiler.jdt.JDTTreeBuilderHelper.createTargetFieldAccess(JDTTreeBuilderHelper.java:663)
	at spoon.support.compiler.jdt.JDTTreeBuilderHelper.createVariableAccess(JDTTreeBuilderHelper.java:267)
	at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:1473)
	at org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference.traverse(QualifiedNameReference.java:1170)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:1170)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:411)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1689)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:822)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:783)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.traverseUnitDeclaration(JDTBasedSpoonCompiler.java:480)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.lambda$buildModel$0(JDTBasedSpoonCompiler.java:437)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.forEachCompilationUnit(JDTBasedSpoonCompiler.java:464)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildModel(JDTBasedSpoonCompiler.java:435)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildUnitsAndModel(JDTBasedSpoonCompiler.java:372)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildSources(JDTBasedSpoonCompiler.java:335)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:116)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:99)
	at spoon.Launcher.buildModel(Launcher.java:772)
	at main.app.main(app.java:628)

I run into this exception at launcher_test.buildModel();

@slarse
Copy link
Collaborator

slarse commented May 25, 2021

Thanks for the bug report!

Could you share the project you're trying to build a model for?

@djaekim
Copy link
Author

djaekim commented May 25, 2021

Thanks for the bug report!

Could you share the project you're trying to build a model for?

I encountered this exception in:

  • Flink@21c44688e9
  • androidx@b5ae05804ed
  • bazel@024deb5826
  • quarkus@997d827693
  • springboot@ae24d66af7
  • vespa@f77660fde6

@slarse
Copy link
Collaborator

slarse commented May 25, 2021

Cool, thanks, problem is reproducible for me. I'm pretty sure this is a duplicate of #3572.

I also think that this is related to ignoring duplicate declarations, because when doing so, it's possible for type bindings to be null. The fix for this bug is trivial, what's going to be tricky is to create a minimal test case.

@slarse
Copy link
Collaborator

slarse commented May 26, 2021

Determined that this is caused by the type binding of a nested type being null when a type binding must be searched for. The whole searching for type bindings is explained in some detail in #3709

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 a pull request may close this issue.

2 participants