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 73634 - Wrong method parameters in code completion for generified interfaces
Summary: Wrong method parameters in code completion for generified interfaces
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 5.x
Hardware: All Windows XP
: P2 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-16 10:07 UTC by m_potociar
Modified: 2007-09-26 09:14 UTC (History)
3 users (show)

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 m_potociar 2006-03-16 10:07:34 UTC
I tried to implement anonymous Comparator class, thus I wrote following code:

private Comparator<PolicyAssertion> assertionComparator = new
Comparator<PolicyAssertion>() {
};

The parser correctly recognized missing method implementation and it provided a
code completion hint to implement all abstract methods, which resulted into
following code:

private Comparator<PolicyAssertion> aassertionComparator = new
Comparator<PolicyAssertion>() {
    public int compare(Object o1, Object o2) {
    }        
};

...which is wrong and parser recognizes this error underlyning the
code-completed method. Proper method signature should have PolicyAssertion input
parameters:

    public int compare(PolicyAssertion o1, PolicyAssertion o2) {
    }
Comment 1 Miloslav Metelka 2006-06-08 21:42:40 UTC
So the problem is after Alt+Enter and clicking "Implement all abstract methods",
right?
It seems that the java hints provider does not care about generics properly. The
code should be in java/hints I guess ImplementMethodJavaHint. Reassigning to
Vita. Adding jlahoda to cc as Honza knows the editor hints best.
Comment 2 Vitezslav Stejskal 2006-06-09 08:15:32 UTC
I've spent some time investigating the problem and here is what I found. The
hint seems to work fine for normal classes no matter whether they use generics
or not. However, it's broken for annonymous classes.

For some reason the ClassDefinition of an annonymous class doesn't seem to know
about the generics. When it's asked to return interfaces implemented by the
annonymous class it simply returns interfaces without the generics type. In the
example mentioned in this defect the ClassDefinition of the annonymous class
returns java.lang.Comparator as the implemented interface. When the same example
is used for non-annonymous class the ClassDefinition returns
java.lang.Comparator<whatever.package.PolicyAssertion> JavaClass and the
provided hint works fine.

Now, I admit that I do not understand how the java model is implemented, but my
impression is that the defect is not in the java hints provider, but in the java
model implementation itself.

Any pointers please?
Comment 3 Vitezslav Stejskal 2006-06-09 09:24:02 UTC
Reassigning to java module.
Comment 4 Jan Becicka 2006-06-26 16:03:16 UTC
we will look at it. The problem is in javacore.
Comment 5 Jan Becicka 2006-06-28 10:56:40 UTC
Checking in javacore/src/org/netbeans/modules/javacore/parser/MDRParser.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/parser/MDRParser.java,v 
<--  MDRParser.java
new revision: 1.100; previous revision: 1.99
done
Checking in hints/src/org/netbeans/modules/java/hints/JavaHintsProvider.java;
/cvs/java/hints/src/org/netbeans/modules/java/hints/JavaHintsProvider.java,v 
<--  JavaHintsProvider.java
new revision: 1.56; previous revision: 1.55
done
Comment 6 Jan Becicka 2006-07-13 09:03:09 UTC
Checking in hints/src/org/netbeans/modules/java/hints/JavaHintsProvider.java;
/cvs/java/hints/src/org/netbeans/modules/java/hints/JavaHintsProvider.java,v 
<--  JavaHintsProvider.java
new revision: 1.41.2.3.2.2; previous revision: 1.41.2.3.2.1
done
Checking in javacore/src/org/netbeans/modules/javacore/parser/MDRParser.java;
/cvs/java/javacore/src/org/netbeans/modules/javacore/parser/MDRParser.java,v 
<--  MDRParser.java
new revision: 1.85.6.4.2.4; previous revision: 1.85.6.4.2.3
done
Comment 7 Quality Engineering 2007-09-20 09:50:34 UTC
Reorganization of java component