Bug 568259 - Scope.isBoxingCompatibleWith(...) throws NullPointerException
Summary: Scope.isBoxingCompatibleWith(...) throws NullPointerException
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.17   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.18 M3   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2020-10-26 13:10 EDT by Ivan Ivan CLA
Modified: 2020-11-17 21:17 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Ivan CLA 2020-10-26 13:10:57 EDT
Tracktrace:

Exception in thread "main" java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.lookup.Scope.isBoxingCompatibleWith(Scope.java:3754)
	at org.eclipse.jdt.internal.compiler.ast.Statement.isBoxingCompatible(Statement.java:448)
	at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.isBoxingCompatibleWith(AllocationExpression.java:555)
	at org.eclipse.jdt.internal.compiler.lookup.ConstraintExpressionFormula.reduce(ConstraintExpressionFormula.java:75)
	at org.eclipse.jdt.internal.compiler.lookup.BoundSet.reduceOneConstraint(BoundSet.java:985)
	at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.reduce(InferenceContext18.java:1072)
	at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.solve(InferenceContext18.java:1023)
	at org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.computeCompatibleMethod18(ParameterizedGenericMethodBinding.java:249)
	at org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.computeCompatibleMethod(ParameterizedGenericMethodBinding.java:92)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:841)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:798)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod0(Scope.java:1756)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:1657)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getImplicitMethod(Scope.java:2627)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:805)
	at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1082)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:664)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:361)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:573)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1490)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1615)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:662)
	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:902)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1044)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:662)
	at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:1001)


Test code:
public final class Main<T extends Object> {

    public static <T extends Object> Main<T> invoke(Object o) {
        return null;
    }

    public void test() {
        invoke(new Main.Inner());
    }
}


Java Development Tools Core version 3.23.0
Comment 1 Andrey Loskutov CLA 2020-10-28 09:03:43 EDT
Regression in 4.17. 4.16 is OK.

Stack from 4.18 head:
java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.lookup.Scope.isBoxingCompatibleWith(Scope.java:3753)
	at org.eclipse.jdt.internal.compiler.ast.Statement.isBoxingCompatible(Statement.java:451)
	at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.isBoxingCompatibleWith(AllocationExpression.java:555)
	at org.eclipse.jdt.internal.compiler.lookup.ConstraintExpressionFormula.reduce(ConstraintExpressionFormula.java:75)
	at org.eclipse.jdt.internal.compiler.lookup.BoundSet.reduceOneConstraint(BoundSet.java:985)
	at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.reduce(InferenceContext18.java:1072)
	at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.solve(InferenceContext18.java:1023)
	at org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.computeCompatibleMethod18(ParameterizedGenericMethodBinding.java:249)
	at org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding.computeCompatibleMethod(ParameterizedGenericMethodBinding.java:92)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:841)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:798)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod0(Scope.java:1756)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:1657)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getImplicitMethod(Scope.java:2626)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:805)
	at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:1113)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:661)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:362)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:570)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1492)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1617)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:662)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1243)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:714)
	at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1205)
	at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:820)
	at org.eclipse.jdt.core.manipulation.CoreASTProvider$1.run(CoreASTProvider.java:272)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.jdt.core.manipulation.CoreASTProvider.createAST(CoreASTProvider.java:264)
	at org.eclipse.jdt.core.manipulation.CoreASTProvider.getAST(CoreASTProvider.java:197)
	at org.eclipse.jdt.core.manipulation.SharedASTProviderCore.getAST(SharedASTProviderCore.java:138)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:166)
	at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$1.run(SelectionListenerWithASTManager.java:151)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Comment 2 Jay Arthanareeswaran CLA 2020-10-28 10:06:47 EDT
This is happening since bug 566125 was fixed. Will take a look.
Comment 3 Eclipse Genie CLA 2020-10-28 10:44:06 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/171405
Comment 4 Jay Arthanareeswaran CLA 2020-10-28 22:42:48 EDT
(In reply to Eclipse Genie from comment #3)
> New Gerrit change created:
> https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/171405

The fix for bug 566125 replaced the call to isCompatibleWith() with isBoxingCompatibleWith(), we also lost a bunch of checks that are required when the allocation expression resolves to a null binding. I have brought those checks back now.
Comment 6 Manoj N Palat CLA 2020-11-17 21:17:03 EST
Verified for Eclipse 4.18 M3 Version: 2020-12 (4.18) with Build id: I20201117-0600