Summary: | NPE during code completion | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Olivier Thomann <Olivier_Thomann> | ||||||
Component: | Core | Assignee: | David Audel <david_audel> | ||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||
Severity: | normal | ||||||||
Priority: | P3 | CC: | remy.suen | ||||||
Version: | 3.4 | ||||||||
Target Milestone: | 3.5 M3 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows XP | ||||||||
Whiteboard: | |||||||||
Attachments: |
|
Description
Olivier Thomann
2008-09-04 16:03:32 EDT
Steps to reproduce: 1) Check out the projects org.eclipse.pde.api.tools and org.eclipse.pde.api.tools.tests from CVS 2) Go to org.eclipse.pde.api.tools.builder.tests.compatibility.ClassCompatibilityHierarchyTests 3) Apply the patch attached to this bug 4) Go to line 174: getChangedProblemId(IDelta.SUPERCLASS) 5) Select "ChangedProblemId(" and do code assist. 6) Select RemovedProblemId and the NPE should occur. Let me know if you have any problem to reproduce. Created attachment 111750 [details]
Patch to apply
Created attachment 115571 [details]
Proposed fix
Hi, I'm hitting this on I20081007-1600. Please invoke code completion inside the parentheses of the getTime() invocation in the getRange() method to reproduce the NPE. I saw this problem in a bigger piece of code I was working on, this is a trimmed down version. I see two different NPEs in my logs although they both point to CompletionOnQualifiedAllocationExpression. public class Test { public static long[] getRange() { return new long[] { getTime() }; } private static long getTime() { return -1; } } java.lang.NullPointerException at org.eclipse.jdt.internal.codeassist.complete.CompletionOnQualifiedAllocationExpression.resolveType(CompletionOnQualifiedAllocationExpression.java:45) at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:913) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:101) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:101) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:101) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:447) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:192) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:406) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1115) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1203) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:540) at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:2538) at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:129) java.lang.NullPointerException at org.eclipse.jdt.internal.codeassist.complete.CompletionOnQualifiedAllocationExpression.resolveType(CompletionOnQualifiedAllocationExpression.java:45) at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:913) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:447) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:192) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:406) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1115) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1203) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:540) at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:2538) Released for 3.5M3. Test added CompletionTests#testArrayInitializer1() Verified for 3.5M3 using I20081026-2000 |