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 236461 - [Code completion] wrongly recognize generic types
Summary: [Code completion] wrongly recognize generic types
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-27 11:15 UTC by ssazonov
Modified: 2013-10-01 11:28 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
step_01 (41.97 KB, image/png)
2013-09-27 11:15 UTC, ssazonov
Details
step_02 (14.69 KB, image/png)
2013-09-27 11:16 UTC, ssazonov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ssazonov 2013-09-27 11:15:27 UTC
1. Create new simple java class ClassG

package simpleproject123;

import java.util.*;

public class ClassG {

    HashMap<Integer, String> nodes = new HashMap<Integer, String>();
    
    public void printById(String s1, Integer p1, String s2){
        
    }
}

2. Put caret into the body of "printById"

3. Type "Object o = nodes.ge", using Ctrl+Space invoke code completion and double-click on "get(Object o) String" value

>> ERR 1:
Code completion have been performed "Object o = nodes.get(s2)" what is wrong. Key value is defined as Integer, so it should be "Object o = nodes.get(p1)".

>> ERR 2:
Rewrit "public void printById(String s1, Integer p1, String s2)" to "public void printById(int p1)" and invoke code completion again on "nodes.ge" (WITHOUT associating to "Object o = ") - a few times I got result "nodes.get(this)" before it have started to recognise correctly: "nodes.get(p1)", perhaps you'll be able to reproduce [ERR 2]

Product Version: NetBeans IDE 7.4 RC2 (Build 201309252201)
Java: 1.7.0_40; Java HotSpot(TM) Client VM 24.0-b56
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b43
System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)
Comment 1 ssazonov 2013-09-27 11:15:49 UTC
Created attachment 140547 [details]
step_01
Comment 2 ssazonov 2013-09-27 11:16:03 UTC
Created attachment 140548 [details]
step_02
Comment 3 Jiri Prox 2013-09-27 11:33:07 UTC
The ERR1 is invalid, method get() is declared as "public V get(Object key)"

I cannot reproduce ERR2, only if I delete all parameters, the code completion use 'this' so maybe it is problem of "fast typing/slow source code scanning"
Comment 4 Dusan Balek 2013-09-30 17:00:44 UTC
Unfortunately, I cannot reproduce the ERR2 either. Could you please try to reproduce the problem while profiling the IDE (using 'Profile the IDE' action)? Thanks.
Comment 5 ssazonov 2013-10-01 11:28:55 UTC
I cannot reproduce ERR2, it seems it occurs very rarely.

I still think ERR1 is not invalid because whenever "Object o = nodes.ge" is autocompleted the hint occurs saying "Given object cannot contain instance of String (expected Integer)".

Product Version: NetBeans IDE 7.4 RC2 (Build 201309302222)
Java: 1.7.0_40; Java HotSpot(TM) Client VM 24.0-b56
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b43
System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)