langtools/test/tools/javac/lambda/BadAccess03.java
author lana
Tue, 25 Apr 2017 07:38:50 +0000
changeset 44909 b53c770dc04f
parent 14547 86d8d242b0c4
permissions -rw-r--r--
Added tag jdk-10+1 for changeset 3a409afd3f86
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     1
/*
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     3
 * @bug 8003280
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     4
 * @summary Add lambda tests
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     5
 *  check lambda cannot assign non-effectively final locals
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     6
 * @compile/fail/ref=BadAccess03.out -XDrawDiagnostics BadAccess03.java
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     7
 */
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     8
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     9
class BadAccess03 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    10
    void test() {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    11
        int k = 0;
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    12
        int n = 2; //effectively final variable
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    13
        Runnable r = ()-> { k = n; }; //error
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    14
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    15
}