Thu, 10 Oct 2013 14:58:04 +0200
8001931: The new build system whitespace cleanup
Reviewed-by: tbell, simonis, erikj
mcimadamore@1297 | 1 | /* |
mcimadamore@1415 | 2 | * @test /nodynamiccopyright/ |
jfranck@2020 | 3 | * @bug 7175538 8003280 |
mcimadamore@1415 | 4 | * @summary Add lambda tests |
mcimadamore@1415 | 5 | * Integrate effectively final check with DA/DU analysis |
mcimadamore@1415 | 6 | * @compile/fail/ref=EffectivelyFinalTest01.out -XDrawDiagnostics EffectivelyFinalTest.java |
mcimadamore@1297 | 7 | * @compile/fail/ref=EffectivelyFinalTest02.out -source 7 -Xlint:-options -XDrawDiagnostics EffectivelyFinalTest.java |
mcimadamore@1297 | 8 | */ |
mcimadamore@1297 | 9 | class EffectivelyFinalTest { |
mcimadamore@1297 | 10 | |
mcimadamore@1297 | 11 | void m1(int x) { |
mcimadamore@1297 | 12 | int y = 1; |
mcimadamore@1297 | 13 | new Object() { { System.out.println(x+y); } }; //ok - both x and y are EF |
mcimadamore@1297 | 14 | } |
mcimadamore@1297 | 15 | |
mcimadamore@1297 | 16 | void m2(int x) { |
mcimadamore@1297 | 17 | int y; |
mcimadamore@1297 | 18 | y = 1; |
mcimadamore@1297 | 19 | new Object() { { System.out.println(x+y); } }; //ok - both x and y are EF |
mcimadamore@1297 | 20 | } |
mcimadamore@1297 | 21 | |
mcimadamore@1297 | 22 | void m3(int x, boolean cond) { |
mcimadamore@1297 | 23 | int y; |
mcimadamore@1297 | 24 | if (cond) y = 1; |
mcimadamore@1297 | 25 | new Object() { { System.out.println(x+y); } }; //error - y not DA |
mcimadamore@1297 | 26 | } |
mcimadamore@1297 | 27 | |
mcimadamore@1297 | 28 | void m4(int x, boolean cond) { |
mcimadamore@1297 | 29 | int y; |
mcimadamore@1297 | 30 | if (cond) y = 1; |
mcimadamore@1297 | 31 | else y = 2; |
mcimadamore@1297 | 32 | new Object() { { System.out.println(x+y); } }; //ok - both x and y are EF |
mcimadamore@1297 | 33 | } |
mcimadamore@1297 | 34 | |
mcimadamore@1297 | 35 | void m5(int x, boolean cond) { |
mcimadamore@1297 | 36 | int y; |
mcimadamore@1297 | 37 | if (cond) y = 1; |
mcimadamore@1297 | 38 | y = 2; |
mcimadamore@1297 | 39 | new Object() { { System.out.println(x+y); } }; //error - y not EF |
mcimadamore@1297 | 40 | } |
mcimadamore@1297 | 41 | |
mcimadamore@1297 | 42 | void m6(int x) { |
mcimadamore@1297 | 43 | new Object() { { System.out.println(x+1); } }; //error - x not EF |
mcimadamore@1415 | 44 | x++; // Illegal: x is not effectively final. |
mcimadamore@1297 | 45 | } |
mcimadamore@1297 | 46 | |
mcimadamore@1297 | 47 | void m7(int x) { |
mcimadamore@1297 | 48 | new Object() { { System.out.println(x=1); } }; //error - x not EF |
mcimadamore@1297 | 49 | } |
mcimadamore@1297 | 50 | |
mcimadamore@1297 | 51 | void m8() { |
mcimadamore@1297 | 52 | int y; |
mcimadamore@1297 | 53 | new Object() { { System.out.println(y=1); } }; //error - y not EF |
mcimadamore@1297 | 54 | } |
mcimadamore@1297 | 55 | } |