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 200592 - Wrong hint for diamond <> operator and anonymous classes
Summary: Wrong hint for diamond <> operator and anonymous classes
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Hints & Annotations (show other bugs)
Version: 7.0
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks: 218321
  Show dependency tree
 
Reported: 2011-08-02 10:19 UTC by choces
Modified: 2012-09-13 21:07 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 choces 2011-08-02 10:19:10 UTC
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 choces 2011-08-02 10:23:20 UTC
Forgot to include system info;

System Info: 
  Product Version         = NetBeans IDE 7.0 (Build 201104080000) (#a693229ccdbb)
  Operating System        = Windows XP version 5.1 running on x86
  Java; VM; Vendor        = 1.7.0; Java HotSpot(TM) Client VM 21.0-b17; Oracle Corporation
  Runtime                 = Java(TM) SE Runtime Environment 1.7.0-b147
Comment 2 Jan Lahoda 2011-08-02 12:24:08 UTC
Yes, NetBeans 7.0 is still based on javac that still proposes this conversion. The newly released NetBeans 7.0.1 uses an up-to-date javac and fixes this problem. Thanks for the report.