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 254270 - Use lambda expression offered to transform anonymous class that references field initialized by new anonymous class
Summary: Use lambda expression offered to transform anonymous class that references fi...
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-11 12:48 UTC by Jachym_Vojtek
Modified: 2015-09-01 09:16 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 Jachym_Vojtek 2015-08-11 12:48:02 UTC
public class EligibleLambdaTests {
    public interface FI1 {

        public void r(int i);
    }

    private FI1 I = new FI1() {
        @Override
        public void r(int i) {
            System.err.println("i=" + I);
        }
    };
}

Applying hint "Use lambda expression" leads to:

private FI1 I = (int i) -> {
    err.println("i=" + I); // self-reference in initializer 
};
Comment 1 Svata Dedic 2015-09-01 09:16:44 UTC
Sorry, could not reproduce. I did not see the warning and the ConvertToLambdaPrecodnitionChecker correctly identified the reference to `I' as uninitialized variable reference.