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 187859 - IDE Improperly marking code with generics as bad
Summary: IDE Improperly marking code with generics as bad
Status: RESOLVED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Compiler (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal with 2 votes (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-21 00:37 UTC by james.kosin
Modified: 2010-06-28 06:38 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description james.kosin 2010-06-21 00:37:00 UTC
Product Version = NetBeans IDE 6.9 (Build 201006101454)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.6.0_20
Runtime = Java HotSpot(TM) 64-Bit Server VM 16.3-b01

A project I use with NetBeans OpenNLP Tools has an issue with a file that doesn't make sence.
The file is HashList.java and it extends Hash.java from the java library.

A snipett of the problem is below.
public class HashList<K, V> extends HashMap<K, List<V>> {

  public List<V> put(K key, V value) {
  }
}

The IDE complains:
name clash: put(K,V) in opennlp.tools.util.HashList and put(K,V) in java.util.HashMap have the same erasure, yet neither overrides the other

I'm a bit vague on the error; however, it didn't complain with version 6.8 and the same code.

Any idea on why this is a problem for the IDE?

Thanks,
James Kosin
Comment 1 james.kosin 2010-06-23 23:32:50 UTC
Any ideas on this issue?
Comment 2 medotin 2010-06-24 18:57:09 UTC
A more basic example exhibiting the problem.  This compiles in 1.6.0_20 but is flagged as an editor error in NB6.9 


public static void main( String[] args )
{
    a(new ArrayList<String>());
    a(new ArrayList<Integer>());
}

public static String a(List<String> l) {return null;}
public static Integer a(List<Integer> l) {return null;}
Comment 3 james.kosin 2010-06-25 00:41:57 UTC
This actually produces 2 errors...

(In reply to comment #2)
> A more basic example exhibiting the problem.  This compiles in 1.6.0_20 but is
> flagged as an editor error in NB6.9 
> public static void main( String[] args )
> {
>     a(new ArrayList<String>());
>     a(new ArrayList<Integer>());
Error here about not finding a() for an Integer type.

> }
> public static String a(List<String> l) {return null;}
> public static Integer a(List<Integer> l) {return null;}
Error here about the name conflict.
Comment 4 Vitezslav Stejskal 2010-06-25 08:01:25 UTC
No idea :-(, but passing to the ones who know...
Comment 5 james.kosin 2010-06-26 00:44:41 UTC
(In reply to comment #4)
> No idea :-(, but passing to the ones who know...

It isn't java that is complaining but the IDE is providing what seems to be improper hints and errors.  I'd wish they where warnings; but, don't know why NB6.9 is the only IDE complaining on this.
Comment 6 Jan Lahoda 2010-06-28 06:38:31 UTC
I am afraid that the error is correct - (loosely speaking) the methods must have different erased parameters, which is not true in the test cases:
public static String a(List<String> l) {return null;}
public static Integer a(List<Integer> l) {return null;}
=>
public static String a(List l) {return null;}
public static Integer a(List l) {return null;}

(return types do not count in this case). It is true that javac from JDK5 and 6 accepted such programs, but it was a bug. Current javac from JDK7 does not AFAIK. NetBeans uses its own copy of javac internally to parse the sources, and NB6.8 and earlier used older versions of javac that had the bug, and NB6.9 uses a newer javac which does not have this bug. Sorry, but I do not think there is anything that should be done.

For the record, the javac bug that relates to this is:
http://bugs.sun.com/view_bug.do?bug_id=6182950
and the specification is JLS 8.4.8.3.