langtools/test/tools/javac/lambda/8051958/T8051958.java
author sadayapalam
Tue, 17 Jan 2017 09:17:10 +0530
changeset 43148 9d11c46bd7bf
parent 32337 c9d3ab9f601c
permissions -rw-r--r--
8171993: AssertionError when compiling method reference with generic code and varargs. Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25846
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
     1
/*
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
     4
 *
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
32337
c9d3ab9f601c 8133671: langtools tests have bad license
alundblad
parents: 25846
diff changeset
     7
 * published by the Free Software Foundation.
25846
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
     8
 *
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    13
 * accompanied this code).
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    14
 *
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    18
 *
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    21
 * questions.
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    22
 */
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    23
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    24
/*
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    25
 * @test
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    26
 * @bug 8051958
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    27
 * @summary Cannot assign a value to final variable in lambda
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    28
 * @compile T8051958.java
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    29
 */
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    30
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    31
class T8051958 {
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    32
    Runnable inst_r = ()-> {
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    33
        final int x;
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    34
        x = 1;
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    35
    };
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    36
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    37
    Runnable static_r = ()-> {
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    38
        final int x;
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    39
        x = 1;
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    40
    };
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    41
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    42
    {
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    43
        Runnable inst_r = ()-> {
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    44
            final int x;
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    45
            x = 1;
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    46
        };
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    47
    }
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    48
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    49
    static {
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    50
        Runnable static_r = ()-> {
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    51
            final int x;
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    52
            x = 1;
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    53
        };
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    54
    }
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    55
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    56
    void instTest() {
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    57
        Runnable static_r = ()-> {
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    58
            final int x;
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    59
            x = 1;
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    60
        };
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    61
    }
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    62
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    63
    static void staticTest() {
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    64
        Runnable static_r = ()-> {
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    65
            final int x;
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    66
            x = 1;
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    67
        };
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    68
    }
e7124d0dc984 8051958: Cannot assign a value to final variable in lambda
mcimadamore
parents:
diff changeset
    69
}