Bug 61507

Summary: [1.5] NPE in computeCompatibleMethod
Product: [Eclipse Project] JDT Reporter: Stefan Matthias Aust <sma>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Stefan Matthias Aust CLA 2004-05-08 13:09:59 EDT
I'm using I200405060200 plus v_150_0507 from CVS. This testcase

public class U {
 static <T> T notNull(T t) { return t; }
}
public class T {
 void t() {
  String s = U.notNull("");
 }
}

raises an "method not applicable" error marker in the editor but not in the
problems view.  If I replace "" with null, I get an internal compiler error.

Internal compiler error
java.lang.NullPointerException
	at
org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:93)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:764)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getMethod(Scope.java:1451)
	at
org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:254)
	at
org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:190)
	at
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:382)
	at
org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:133)

If I put both methods into one class, I can't even save the code and get a "save
problem: Save could not be completed" error.  From the log:

!ENTRY org.eclipse.jdt.core 4 4 Mai 08, 2004 18:55:24.227
!MESSAGE Exception occurred during problem detection: 
!STACK 0
java.lang.NullPointerException
	at
org.eclipse.jdt.internal.compiler.lookup.Scope.computeCompatibleMethod(Scope.java:93)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.findMethod(Scope.java:764)
	at
org.eclipse.jdt.internal.compiler.lookup.BlockScope.getImplicitMethod(BlockScope.java:776)
	at
org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:253)
	at
org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:190)
	at
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:382)
	at
org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:133)
	at
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:359)
	at
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:925)
	at
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:974)
	at
org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:280)
Comment 1 Philipe Mulet CLA 2004-05-09 09:32:55 EDT
We were not properly handling null types during type inference.
Added regression test: GenericTypeTest#test179.
Comment 2 Philipe Mulet CLA 2004-05-09 09:33:08 EDT
Fixed.