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

NPE in spoon.support.compiler.jdt.ReferenceBuilder.tryRecoverTypeArguments(ReferenceBuilder.java:611) #3594

Open
Strum355 opened this issue Sep 14, 2020 · 1 comment

Comments

@Strum355
Copy link
Contributor

In a code sample similar to the following:

Code sample
private GrpcToReactorMethodBinding findReactorMethod(MethodDescriptor<?, ?> methodDescriptor) {
        // ...

        // Check method arguments
        if (reactorMethod.getParameterCount() == 0) {
            // ...
            return new GrpcToReactorMethodBinding<>(methodDescriptor, reactorMethod, -1, isMono, returnTypeParameter);
        }
	// ...
}

a NPE is thrown on ReferenceBuilder.java:611 as ParameterizedTypeBinding.typeArguments is a null array, with alloc.sourceStart pointing to the start of the new keyword.

Excerpt of GrpcToReactorMethodBinding is as follows:

GrpcToReactorMethodBinding code
class GrpcToReactorMethodBinding<REQ, RESP> {

    // ...

    GrpcToReactorMethodBinding(MethodDescriptor<REQ, RESP> methodDescriptor,
                               Method reactorMethod,
                               int callMetadataPos,
                               boolean isMono,
                               Class returnTypeParameter) {
		// ...
    }
	// ...
}
Stacktrace
Exception in thread "main" java.lang.NullPointerException: Cannot read the array length because "<local5>" is null
	at spoon.support.compiler.jdt.ReferenceBuilder.tryRecoverTypeArguments(ReferenceBuilder.java:611)
	at spoon.support.compiler.jdt.ReferenceBuilder.insertGenericTypesInNoClasspathFromJDTInSpoon(ReferenceBuilder.java:575)
	at spoon.support.compiler.jdt.ReferenceBuilder.getTypeReference(ReferenceBuilder.java:517)
	at spoon.support.compiler.jdt.ReferenceBuilder.buildTypeReference(ReferenceBuilder.java:136)
	at spoon.support.compiler.jdt.ReferenceBuilder.buildTypeReference(ReferenceBuilder.java:130)
	at spoon.support.compiler.jdt.JDTTreeBuilder.createParameterizedType(JDTTreeBuilder.java:1450)
	at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:1438)
	at org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.traverse(ParameterizedSingleTypeReference.java:405)
	at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.traverse(AllocationExpression.java:713)
	at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse(ReturnStatement.java:379)
	at org.eclipse.jdt.internal.compiler.ast.Block.traverse(Block.java:148)
	at org.eclipse.jdt.internal.compiler.ast.IfStatement.traverse(IfStatement.java:293)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:365)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1479)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:826)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:787)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.lambda$buildModel$0(JDTBasedSpoonCompiler.java:437)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.forEachCompilationUnit(JDTBasedSpoonCompiler.java:466)
	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:337)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:114)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:97)
	at spoon.Launcher.buildModel(Launcher.java:755)
	at lsifjava.ProjectIndexer.index(ProjectIndexer.java:125)
	at lsifjava.Main.main(Main.java:18)
@monperrus
Copy link
Collaborator

Thanks @Strum355, are you trying to fix it?

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

2 participants