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 257008 - Hint anounced not read variable despite it is
Summary: Hint anounced not read variable despite it is
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: -FFJ-
Hardware: PC All
: P4 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-06 14:45 UTC by rudyment
Modified: 2016-08-11 01:56 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 rudyment 2015-12-06 14:45:19 UTC
Product Version = NetBeans IDE 8.1 (Build 201510222201)
Operating System = Windows 10 version 10.0 running on amd64
Java; VM; Vendor = 1.8.0_65
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.65-b01

Reproducibility: Happens every time

In the following code the editor announced that the array count is only written to but never read from.
However it is read four lines later in the condition of the if statement

public RupStream<T> limit(long maxSize)
{
    final long[] count = {0};     //Variable wrapped into constant
    Supplier<Optional<T>> outputGenerator = () ->
        {
            Optional<T> oInput = generator.get();
            if (! oInput.isPresent()  ||  (++count[0] > maxSize)) {
                return Optional.empty();
            }
            return oInput;
        };
    RupStream<T> output = new RupStream<>(outputGenerator);
    return output;
}
Comment 1 Jiri Prox 2015-12-08 14:19:43 UTC
reproducible

reduced code:

    public void test() {
        final long[] count = {0};            
        if(++count[0] ==1 ) {            
        }
    }
Comment 2 Svata Dedic 2016-08-04 15:14:31 UTC
Fixed in jet-main#729b9b4e387e
Comment 3 Quality Engineering 2016-08-11 01:56:53 UTC
Integrated into 'main-silver', will be available in build *201608110002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/729b9b4e387e
User: Svata Dedic <sdedic@netbeans.org>
Log: #257008: inc/dec operators are treated as read+write