test/tools/javac/lambda/EffectivelyFinalTest.java

changeset 1415
01c9d4161882
parent 1297
e5cf1569d3a4
child 2020
bb7271e64ef6
equal deleted inserted replaced
1414:843d3b191773 1415:01c9d4161882
1 /* 1 /*
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 2 * @test /nodynamiccopyright/
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * @bug 8003280
4 * 4 * @summary Add lambda tests
5 * This code is free software; you can redistribute it and/or modify it 5 * Integrate effectively final check with DA/DU analysis
6 * under the terms of the GNU General Public License version 2 only, as 6 * @compile/fail/ref=EffectivelyFinalTest01.out -XDrawDiagnostics EffectivelyFinalTest.java
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @summary Integrate efectively final check with DA/DU analysis
27 * @compile/fail/ref=EffectivelyFinalTest01.out -XDallowEffectivelyFinalInInnerClasses -XDrawDiagnostics EffectivelyFinalTest.java
28 * @compile/fail/ref=EffectivelyFinalTest02.out -source 7 -Xlint:-options -XDrawDiagnostics EffectivelyFinalTest.java 7 * @compile/fail/ref=EffectivelyFinalTest02.out -source 7 -Xlint:-options -XDrawDiagnostics EffectivelyFinalTest.java
29 */ 8 */
30 class EffectivelyFinalTest { 9 class EffectivelyFinalTest {
31 10
32 void m1(int x) { 11 void m1(int x) {
60 new Object() { { System.out.println(x+y); } }; //error - y not EF 39 new Object() { { System.out.println(x+y); } }; //error - y not EF
61 } 40 }
62 41
63 void m6(int x) { 42 void m6(int x) {
64 new Object() { { System.out.println(x+1); } }; //error - x not EF 43 new Object() { { System.out.println(x+1); } }; //error - x not EF
65 x++; 44 x++; // Illegal: x is not effectively final.
66 } 45 }
67 46
68 void m7(int x) { 47 void m7(int x) {
69 new Object() { { System.out.println(x=1); } }; //error - x not EF 48 new Object() { { System.out.println(x=1); } }; //error - x not EF
70 } 49 }

mercurial