aoqi@0: /* aoqi@0: * @test /nodynamiccopyright/ aoqi@0: * @bug 8003280 aoqi@0: * @summary Add lambda tests aoqi@0: * Negative test of capture of "effectively final" local variable in lambda expressions aoqi@0: * @compile/fail/ref=EffectivelyFinal_neg.out -XDrawDiagnostics EffectivelyFinal_neg.java aoqi@0: */ aoqi@0: aoqi@0: public class EffectivelyFinal_neg { aoqi@0: aoqi@0: void test() { aoqi@0: String s = "a"; aoqi@0: String s2 = "a"; aoqi@0: int n = 1; aoqi@0: ((Runnable) aoqi@0: ()-> { aoqi@0: s2 = "b"; //re-assign illegal here aoqi@0: System.out.println(n); aoqi@0: System.out.println(s); aoqi@0: s = "b"; // not effectively final aoqi@0: } aoqi@0: ).run(); aoqi@0: n = 2; // not effectively final aoqi@0: } aoqi@0: }