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 218321 - Wrong hint for diamond <> operator and anonymous classes
Summary: Wrong hint for diamond <> operator and anonymous classes
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.2
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on: 200592
Blocks:
  Show dependency tree
 
Reported: 2012-09-13 21:07 UTC by wgabrie
Modified: 2012-09-24 12:00 UTC (History)
1 user (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 wgabrie 2012-09-13 21:07:18 UTC
I am using NetBeans 7.2 and Java 1.7.0_07 on Windows XP. Netbeans keeps bothering me to change my existing diamond operators to be empty, example:

existing code: List<Point2D> pointList = new ArrayList<Point2D>();
netbeans hint: List<Point2D> pointList = new ArrayList<>();

It removes the contents of the diamond operator. I know this is a clone of an existing bug that was closed, but the issue is happening again in my later version of netbeans/java se.

+++ This bug was initially created as a clone of Bug #200592 +++

Let's have a code block like the following one:

  final Callable<String> callable = new Callable<String>() {

            @Override
            public String call() throws Exception {
                return "test";
            }
        };

Hints suggest to use diamond inference, so above code would be changed to:

 final Callable<String> callable = new Callable<>() {

            @Override
            public String call() throws Exception {
                return "test";
            }
        };

But the lattest code will not compile, due to:

 error: cannot infer type arguments for Callable;
        final Callable<String> callable = new Callable<>() {
  reason: cannot use '<>' with anonymous inner classes
Comment 1 wgabrie 2012-09-13 21:13:18 UTC
Just to add. I just tested the netbeans build feature and the empty diamond operator does compile, so it isn't a compiler bug, but I want this diamond inference warning to stop bothering me when I'm using valid syntax.
Comment 2 Quality Engineering 2012-09-23 02:12:33 UTC
Integrated into 'main-golden', will be available in build *201209230001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/f7995c6e165a
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #218321: use java.hints' ErrorDescriptionFactory to get the standard subfixes.
Comment 3 Jan Lahoda 2012-09-24 12:00:07 UTC
Do I understand correctly that this is not about generating incorrect code (the code is still valid after the change, right?)? Bug #200592 was about removing the type parameters in case where they had to be kept.

The hint can be disabled in Tools/Options/Editor/Hints/Language=Java/JDK 1.5 and later/Can Use Diamond. It was missing the standard subfixes, which I added using the changeset above, so in the next release "Configure" and "Disable" options should be available directly from the editor.