Bug 197400 - NPE for completion engine in class static block
Summary: NPE for completion engine in class static block
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.4 M1   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-21 14:08 EDT by Benjamin Ranck CLA
Modified: 2007-08-03 09:33 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix (3.68 KB, patch)
2007-07-26 07:46 EDT, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Ranck CLA 2007-07-21 14:08:51 EDT
Build ID: I20070621-1340

Steps To Reproduce:
Using this code
====
public class Test {
	static {
		<>
	}
}
====
Try autocomplete within the <> area. The NPE will be thrown. 

More information:
This was first found in eclipse 3.2 and reproducible in 3.3.
Comment 1 Dani Megert CLA 2007-07-23 03:56:46 EDT
Sorry, I cannot reproduce this using plain Eclipse SDK.
Comment 2 Benjamin Ranck CLA 2007-07-24 09:33:27 EDT
I also tested with this build on another machine
Version: 3.2.2
Build id: M20070212-1330

with a static block

static{<>}

and then try auto-completing, ie ctrl-space within the angle brackets.

Here's the top of the stack trace:

!ENTRY org.eclipse.jdt.ui 2 0 2007-07-19 17:34:43.006
!MESSAGE The 'org.eclipse.jdt.ui.JavaNoTypeCompletionProposalComputer' proposal computer from the 'org.eclipse.jdt.ui' plug-in did not complete normally. The extension has thrown a runtime exception.
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.buildMoreGenericsCompletionContext(CompletionParser.java:878)
	at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.attachOrphanCompletionNode(CompletionParser.java:399)
	at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.updateRecoveryState(CompletionParser.java:3794)
	at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError(Parser.java:9915)
Comment 3 Dani Megert CLA 2007-07-24 09:44:57 EDT
Sorry but not here. Either your test case is not complete or you are not using plain Eclipse SDK.

1. download Eclipse SDK (I tested R3.2.2. R3.3 and latest I-build) and
   install into an empty directory
2. start with new workspace
3. paste the following into Package Explorer:
public class Test {
        static {
                <>
        }
}
4. replace <> with the caret
5. Ctrl+Space
==> no exception.

Please provide more details.

Moving to JDT Core as the exception happens there.
Comment 4 David Audel CLA 2007-07-26 05:30:11 EDT
I can reproduce the problem with this test case

public class Test {
        static {
                <|> // do ctrl+space at | location
        }
}
Comment 5 Dani Megert CLA 2007-07-26 05:34:06 EDT
>I can reproduce the problem with this test case
Me too ;-) I replaced <> with the caret instead of doing code assist with <>.
Comment 6 David Audel CLA 2007-07-26 07:46:05 EDT
Created attachment 74671 [details]
Proposed fix
Comment 7 David Audel CLA 2007-07-26 07:48:34 EDT
Released for 3.4M1.

Tests added
  GenericsCompletionParserTest#test0214_Diet()
  GenericsCompletionParserTest#test0214_Method()
Comment 8 Frederic Fusier CLA 2007-08-03 09:33:49 EDT
Verified for 3.4M1 using build I20070802-0800.