Bug 61507 - [1.5] NPE in computeCompatibleMethod
Summary: [1.5] NPE in computeCompatibleMethod
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-08 13:09 EDT by Stefan Matthias Aust CLA
Modified: 2005-01-11 11:02 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.