INRIA / spoon

Spoon is a metaprogramming library to analyze and transform Java source code. :spoon: is made with :heart:, :beers: and :sparkles:. It parses source files to build a well-designed AST with powerful analysis and transformation API.
http://spoon.gforge.inria.fr/
Other
1.74k stars 347 forks source link

NullPointerException on CtTypeReferenceImpl.isGenerics #3275

Closed ontologiae closed 4 years ago

ontologiae commented 4 years ago

Hi,

I have an error parsing this file (This codebase leverage several bugs, you should use it) after L87 of this file : https://github.com/metasfresh/metasfresh/blob/70a820840dde9b73783c52ec72e02c9f611df281/de.metas.adempiere.libero.libero/src/main/java/org/eevolution/costing/BOMCostPrice.java#L87 It's the last reference I have on this file. My code test before calling isGeneric that the receiver is not null. The last token that lead to call isGeneric is a CtInvocation

Here's the stacktrace :

[error] (run-main-1) java.lang.NullPointerException
[error] java.lang.NullPointerException
[error]     at spoon.support.reflect.reference.CtTypeParameterReferenceImpl.getDeclaration(CtTypeParameterReferenceImpl.java:131)
[error]     at spoon.support.reflect.reference.CtTypeParameterReferenceImpl.isGenerics(CtTypeParameterReferenceImpl.java:195)
[error]     at spoon.support.reflect.reference.CtTypeReferenceImpl.isGenerics(CtTypeReferenceImpl.java:845)
[error]     at org.deepanalyzer.javaparse.Parser.extractType(Parser.scala:546)
[error]     at org.deepanalyzer.javaparse.Parser.descendExpression(Parser.scala:951)
MartinWitt commented 4 years ago

i have reproduce your bug, currently looking into it. Edit: The problem is, that if (!parentExec.getDeclaringType().equals(e)) getDeclaringType returns null

https://github.com/INRIA/spoon/blob/master/src/main/java/spoon/support/reflect/reference/CtTypeParameterReferenceImpl.java#L131

monperrus commented 4 years ago

closed per #3276