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 256672 - Incorrect warning in a method about collection only being added to, when it actually gets returned
Summary: Incorrect warning in a method about collection only being added to, when it a...
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-18 18:27 UTC by ralphlevan
Modified: 2016-05-26 11:34 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 ralphlevan 2015-11-18 18:27:22 UTC
I have a trivial method that creates an ArrayList and returns it.  The declaration of the ArrayList gets an incorrect hint that "The collection is only added to, never read".

Here's the method:
        static List<Tuple> asList(Tuple[] t, int num) {
            ArrayList<Tuple> v=new ArrayList<Tuple>();
            for(int i=0; i<num; i++)
                v.add(t[i]);
            return v;
        }

I believe this problem is new in 8.1.

Thanks!

Ralph
Comment 1 Svata Dedic 2016-05-26 11:34:37 UTC
Sorry - I could not reproduce the defect. I used 8.1 build #201510222201