test/tools/javac/lambda/8051958/T8051958.java

Wed, 24 Sep 2014 11:38:26 -0700

author
katleman
date
Wed, 24 Sep 2014 11:38:26 -0700
changeset 2562
ed1a48bedfa8
parent 2558
d560276b8a35
permissions
-rw-r--r--

Added tag jdk8u40-b07 for changeset 2fa3858a281f

mcimadamore@2558 1 /*
mcimadamore@2558 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
mcimadamore@2558 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mcimadamore@2558 4 *
mcimadamore@2558 5 * This code is free software; you can redistribute it and/or modify it
mcimadamore@2558 6 * under the terms of the GNU General Public License version 2 only, as
mcimadamore@2558 7 * published by the Free Software Foundation. Oracle designates this
mcimadamore@2558 8 * particular file as subject to the "Classpath" exception as provided
mcimadamore@2558 9 * by Oracle in the LICENSE file that accompanied this code.
mcimadamore@2558 10 *
mcimadamore@2558 11 * This code is distributed in the hope that it will be useful, but WITHOUT
mcimadamore@2558 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mcimadamore@2558 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mcimadamore@2558 14 * version 2 for more details (a copy is included in the LICENSE file that
mcimadamore@2558 15 * accompanied this code).
mcimadamore@2558 16 *
mcimadamore@2558 17 * You should have received a copy of the GNU General Public License version
mcimadamore@2558 18 * 2 along with this work; if not, write to the Free Software Foundation,
mcimadamore@2558 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mcimadamore@2558 20 *
mcimadamore@2558 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mcimadamore@2558 22 * or visit www.oracle.com if you need additional information or have any
mcimadamore@2558 23 * questions.
mcimadamore@2558 24 */
mcimadamore@2558 25
mcimadamore@2558 26 /*
mcimadamore@2558 27 * @test
mcimadamore@2558 28 * @bug 8051958
mcimadamore@2558 29 * @summary Cannot assign a value to final variable in lambda
mcimadamore@2558 30 * @compile T8051958.java
mcimadamore@2558 31 */
mcimadamore@2558 32
mcimadamore@2558 33 class T8051958 {
mcimadamore@2558 34 Runnable inst_r = ()-> {
mcimadamore@2558 35 final int x;
mcimadamore@2558 36 x = 1;
mcimadamore@2558 37 };
mcimadamore@2558 38
mcimadamore@2558 39 Runnable static_r = ()-> {
mcimadamore@2558 40 final int x;
mcimadamore@2558 41 x = 1;
mcimadamore@2558 42 };
mcimadamore@2558 43
mcimadamore@2558 44 {
mcimadamore@2558 45 Runnable inst_r = ()-> {
mcimadamore@2558 46 final int x;
mcimadamore@2558 47 x = 1;
mcimadamore@2558 48 };
mcimadamore@2558 49 }
mcimadamore@2558 50
mcimadamore@2558 51 static {
mcimadamore@2558 52 Runnable static_r = ()-> {
mcimadamore@2558 53 final int x;
mcimadamore@2558 54 x = 1;
mcimadamore@2558 55 };
mcimadamore@2558 56 }
mcimadamore@2558 57
mcimadamore@2558 58 void instTest() {
mcimadamore@2558 59 Runnable static_r = ()-> {
mcimadamore@2558 60 final int x;
mcimadamore@2558 61 x = 1;
mcimadamore@2558 62 };
mcimadamore@2558 63 }
mcimadamore@2558 64
mcimadamore@2558 65 static void staticTest() {
mcimadamore@2558 66 Runnable static_r = ()-> {
mcimadamore@2558 67 final int x;
mcimadamore@2558 68 x = 1;
mcimadamore@2558 69 };
mcimadamore@2558 70 }
mcimadamore@2558 71 }

mercurial