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

Summary: Incorrect warning in a method about collection only being added to, when it actually gets returned
Product: java Reporter: ralphlevan <ralphlevan>
Component: HintsAssignee: Svata Dedic <sdedic>
Status: RESOLVED WORKSFORME    
Severity: normal    
Priority: P3    
Version: 8.1   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

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