Summary: | NullPointerexception on List.toArray + F3 | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | MH <mhilpert> | ||||
Component: | Core | Assignee: | David Audel <david_audel> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | david_audel, eric_jodet | ||||
Version: | 3.3 | ||||||
Target Milestone: | 3.4 M4 | ||||||
Hardware: | PC | ||||||
OS: | Windows 2000 | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
MH
2007-11-13 07:31:11 EST
I don't reproduce the bug with the following classes. // p/Test.java package p; import java.util.ArrayList; import java.util.List; import q.Mine; public class Test { void foo() { final List<Mine> mines = new ArrayList<Mine>(); mines.toArray(new Mine[mines.size()]); } } // q/Mine.java package q; public class Mine { } Could you give me a more complete test case ? I would need the file which contains the declaration of 'Mine' and the file which contains the declaration of 'mines' and the call to 'toArray'. Well, the code I posted just was an examply. The real code is a quite big server application. At least, you need to add some elements into the list as the real code always has elements in it ... but this shouldn't have an effect on F3, should it? Can't you see something from the stack traces I posted? From the source of the corresponding eclipse files: java.lang.NullPointerException at org.eclipse.jdt.internal.core.SelectionRequestor.acceptBinaryMethod(SelectionRequestor.java:152) ? By looking the stacktrace i can only deduce a partial fix. This partial fix would avoid the NPE but would not fix the real problem. The problem is in SelectionRequestor.acceptBinaryMethod(): IMethod[] methods = type.findMethods(method); if (methods.length > 1) { 'methods' is null and should not. The partial fix would be to add only a null check but the real problem is that 'methods' shouldn't be null. If you can't give me the full source that cause the bug could you try to build a smaller test case that reproduce the bug ? Do you reproduce the bug with the following test case ? // p/Test.java package p; import java.util.ArrayList; import java.util.List; import ???.Mine; // replace ??? with the right package name public class Test { void foo() { final List<Mine> mines = new ArrayList<Mine>(); mines.toArray(new Mine[mines.size()]); } } Hm, nope - I can't reproduce it... even in the original case where I got this error on the day I posted this bug report. Too bad ... :-( I guess, this bug will be closed as "won't fix" or "worksforme" ... ? (In reply to comment #5) > > I guess, this bug will be closed as "won't fix" or "worksforme" ... ? > No, the partial fix is sufficient to avoid the NPE. So even if the behavior isn't perfect, it will be better than now. Created attachment 83226 [details]
Proposed fix
This fix add only a null check
Released for 3.4M4. Verified in the code for 3.4 M4 using build I20071210-1800 |