This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 146670 - [65cat] Code completion on Collection.sort(<collection>,<comparator>) Produces Duplicate Results
Summary: [65cat] Code completion on Collection.sort(<collection>,<comparator>) Produce...
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker with 1 vote (vote)
Assignee: Dusan Balek
URL:
Keywords:
: 146659 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-09-09 16:26 UTC by rajivderas
Modified: 2008-09-20 01:19 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screen Shot (127.96 KB, image/png)
2008-09-09 16:40 UTC, rajivderas
Details
stacktrace (3.40 KB, text/plain)
2008-09-15 13:12 UTC, _ alexlamsl
Details
stacktrace (3.31 KB, text/plain)
2008-09-15 14:50 UTC, _ alexlamsl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rajivderas 2008-09-09 16:26:44 UTC
Steps to reproduce: 
1) Create Java Project
2) In the project create a new Java class file
3) Then create a dummy method
4) Inside the dummy method type the following lines - Collections.sort(new 
5) The code completion will popup in the editor with multiple results of each data structure for example if you type 
Collections.sort(new Arr you will find two results with ArrayList<T>


Dev Build 200809081401
JDK 6 Update 10
Comment 1 rajivderas 2008-09-09 16:40:06 UTC
Created attachment 69430 [details]
Screen Shot
Comment 2 Jan Lahoda 2008-09-10 08:21:00 UTC
Not sure why this was a P2 - could you please elaborate on that?
Comment 3 rajivderas 2008-09-10 08:41:21 UTC
jlahoda>>>
I cant use the Collections.sort() in any of my projects thats why
Comment 4 Jan Lahoda 2008-09-10 08:48:40 UTC
Sorry, but I still do not understand - how are you blocked by duplicated entries in the code completion?
Comment 5 rajivderas 2008-09-10 09:35:31 UTC
follow the given steps to reproduce the bug then you will figure out
Comment 6 Dusan Balek 2008-09-10 09:45:39 UTC
*** Issue 146659 has been marked as a duplicate of this issue. ***
Comment 7 Jan Lahoda 2008-09-10 09:49:37 UTC
I followed the steps. I see duplicated entries and get an exception (issue #146659). I can use the CC to fill in
ArrayList using non-smart code completion. I can write new ArrayList() manually, so I can use Collections.sort(new
ArrayList()); (which, BTW, seems as a completely useless code to me).
Comment 8 rajivderas 2008-09-10 11:11:17 UTC
>>>I followed the steps. I see duplicated entries and get an exception (issue #146659). 

If you see duplicated entries and get an exception when using code completion then please fix that issues.

>>>I can use the CC to fill in ArrayList using non-smart code completion. I can write new ArrayList() manually, so I 
>>>can use Collections.sort(new ArrayList()); (which, BTW, seems as a completely useless code to me).

What is the purpose of having code completion then ,if the developers use non-smart code completion ??? Then we don't 
need a IDE ... also don't worry about the code.
Comment 9 Jan Lahoda 2008-09-10 13:52:17 UTC
I would like to clarify a few things (please do not take this personally):
-no-one is arguing that the duplicated entries and exception are not a bug - it is a bug and dbalek is the correct
person to fix this.
-I still think this does not qualify as a P2 - the code completion does not work properly in some cases (most likely not
so much common). If this would be a P2, what priority would be hypothetical bug that the CC does not work at all? What
priority would be that the IDE leaks a lot? Making all issues P2 and P1 is not very helpful.
-I think that when filling a P2 or P1 bug, the reporter should ensure that the reasons for the priority are clear -
either  the priority is automatically justified (e.g. deadlock), or the bug should contain a clear explanation
-the justification "I cant use the Collections.sort() in any of my projects thats why" is not true - you can use the
Collections.sort, only the CC will not be very helpful. If the justification would be "the CC does not work properly in
this case, and I think it is quite common case" or "happens to me very often, very annoying", I still could disagree
(and we might discuss about it, if necessary), but the justifications as such would be true.
Comment 10 rajivderas 2008-09-10 14:46:49 UTC
>>>jlahoda
>>>the bug should contain a clear explanation
>>>-the justification "I cant use the Collections.sort() in any of my projects thats why" is not true - you can use the
>>>Collections.sort, only the CC will not be very helpful

The main problem is usability. I changed it to P2 due to the following description i found in the following link [1]Bug Priority Guidelines. 
My comments regarding "I cant use the Collections.sort() in any of my projects thats why" was a quick explanation about my case to the 
developer and i didn't use it intentionally as a justification to my problem. I made my judgment mainly by referencing the following links 
usability section which clearly states "Critical usability problem
Improperly or inconsistently named or ordered item in main menu, project contextual menu, editor contextual menu, new file wizard, new 
project wizard and main toolbar."

[1]http://wiki.netbeans.org/BugPriorityGuidelines#section-BugPriorityGuidelines-P2


Comment 11 _ alexlamsl 2008-09-15 13:11:51 UTC
Build: NetBeans IDE Dev (Build 200809120201)
VM: Java HotSpot(TM) Client VM, 10.0-b23, Java(TM) SE Runtime Environment, 1.6.0_07-b06
OS: Windows XP, 5.1, x86

User Comments: 
final Set<OrderedSet<T>> result = Hash|

Stacktrace: 
java.lang.IllegalArgumentException: <none>
        at com.sun.tools.javac.model.JavacTypes.getWildcardType(JavacTypes.java:209)
        at org.netbeans.api.java.source.TypeMirrorHandle.resolve(TypeMirrorHandle.java:307)
        at org.netbeans.api.java.source.TypeMirrorHandle.resolve(TypeMirrorHandle.java:263)
        at org.netbeans.api.java.source.TypeMirrorHandle.resolve(TypeMirrorHandle.java:294)
        at org.netbeans.api.java.source.TypeMirrorHandle.resolve(TypeMirrorHandle.java:263)
        at org.netbeans.api.java.source.TypeMirrorHandle.resolve(TypeMirrorHandle.java:263)
Comment 12 _ alexlamsl 2008-09-15 13:12:00 UTC
Created attachment 69862 [details]
stacktrace
Comment 13 _ alexlamsl 2008-09-15 14:50:24 UTC
Build: NetBeans IDE Dev (Build 200809120201)
VM: Java HotSpot(TM) Client VM, 10.0-b23, Java(TM) SE Runtime Environment, 1.6.0_07-b06
OS: Windows XP, 5.1, x86

User Comments: 
code completion with generics
specifically <T extends Comparable<? super T>>

Stacktrace: 
java.lang.IllegalArgumentException: <none>
        at com.sun.tools.javac.model.JavacTypes.getWildcardType(JavacTypes.java:209)
        at org.netbeans.api.java.source.TypeMirrorHandle.resolve(TypeMirrorHandle.java:307)
        at org.netbeans.api.java.source.TypeMirrorHandle.resolve(TypeMirrorHandle.java:263)
        at org.netbeans.api.java.source.TypeMirrorHandle.resolve(TypeMirrorHandle.java:294)
        at org.netbeans.api.java.source.TypeMirrorHandle.resolve(TypeMirrorHandle.java:263)
        at org.netbeans.api.java.source.TypeMirrorHandle.resolve(TypeMirrorHandle.java:218)
Comment 14 _ alexlamsl 2008-09-15 14:50:30 UTC
Created attachment 69871 [details]
stacktrace
Comment 15 _ alexlamsl 2008-09-15 14:56:39 UTC
It is not just Collection.sort() which triggers this problem - I have it blinking at me for nearly everything to do 
with generics when editing code inside a static method with a generic parameter.

Given the fact that an error dialog pops up every single time I try to type "." etc., because CC pops up by default 
and triggers this bug, and also because in development builds the logger pops up whenever there is an exception, IMHO 
this is a serious usability issue.

(And by workaround - I hope you don't mean not using Code Completion altogether. In which case - even P1 bugs have 
workarounds...)
Comment 16 Jan Lahoda 2008-09-15 15:06:18 UTC
If the problem is happening a lot, I have no problems with P2. But, I have never seen the problem myself and the
original report talked only about Collections.sort(new |), which does not seem to justify P2.
Comment 17 rajivderas 2008-09-15 15:14:09 UTC
>>>alexlams
>>>IMHO this is a serious usability issue

alex could you please explain this in a simple manner to  the developers (jlahoda,dbalek) because i explained them 
about this matter and got fed up with them and your doing me a great favour by helping me out to explain this matter to 
them
Comment 18 _ alexlamsl 2008-09-15 15:34:49 UTC
I've just found out that it is not static methods only - but any methods with a return type which has any generic 
parameters.

Whenever I tried to type my "return" statement that creates a class with generic parameter, the error dialog pops up.
Comment 19 Dusan Balek 2008-09-17 12:55:03 UTC
Fixed.

changeset 8aabf401d3cb in main/nb-javac
details: http://hg.netbeans.org/main/nb-javac?cmd=changeset;node=8aabf401d3cb
changeset 2b23053cc9ab in main
details: http://hg.netbeans.org/main?cmd=changeset;node=2b23053cc9ab
Comment 20 Quality Engineering 2008-09-18 05:32:18 UTC
Integrated into 'main-golden', will be available in build *200809180201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/2b23053cc9ab
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #146670: Code completion on Collection.sort(<collection>,<comparator>) Produces Duplicate Results - fixed.
Comment 21 _ alexlamsl 2008-09-20 01:19:49 UTC
Verified on 200809181401