langtools/test/tools/javac/lambda/LocalVariableTable.java
author jjg
Fri, 18 Oct 2013 15:03:34 -0700
changeset 21477 02dc78554e0c
child 29772 4e4e74b99d27
permissions -rw-r--r--
8026749: Missing LV table in lambda bodies Reviewed-by: vromero, jlahoda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21477
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
     1
/*
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
     4
 *
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
     8
 *
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    13
 * accompanied this code).
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    14
 *
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    18
 *
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    21
 * questions.
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    22
 */
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    23
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    24
/*
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    25
 * @test
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    26
 * @bug 8025998 8026749
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    27
 * @summary Missing LV table in lambda bodies
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    28
 * @compile -g LocalVariableTable.java
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    29
 * @run main LocalVariableTable
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    30
 */
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    31
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    32
import java.io.*;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    33
import java.lang.annotation.*;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    34
import java.util.*;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    35
import com.sun.tools.classfile.*;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    36
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    37
/*
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    38
 * The test checks that a LocalVariableTable attribute is generated for the
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    39
 * method bodies representing lambda expressions, and checks that the expected
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    40
 * set of entries is found in the attribute.
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    41
 *
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    42
 * Since the bug was about missing entries in the LVT, not malformed entries,
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    43
 * the test is not intended to be a detailed test of the contents of each
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    44
 * LocalVariableTable entry: it is assumed that if a entry is present, it
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    45
 * will have the correct contents.
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    46
 *
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    47
 * The test looks for test cases represented by nested classes whose
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    48
 * name begins with "Lambda".  Each such class contains a lambda expression
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    49
 * that will mapped into a lambda method, and because the test is compiled
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    50
 * with -g, these methods should have a LocalVariableTable.  The set of
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    51
 * expected names in the LVT is provided in an annotation on the class for
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    52
 * the test case.
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    53
 */
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    54
public class LocalVariableTable {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    55
    public static void main(String... args) throws Exception {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    56
        new LocalVariableTable().run();
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    57
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    58
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    59
    void run() throws Exception {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    60
        // the declared classes are returned in an unspecified order,
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    61
        // so for neatness, sort them by name before processing them
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    62
        Class<?>[] classes = getClass().getDeclaredClasses();
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    63
        Arrays.sort(classes, (c1, c2) -> c1.getName().compareTo(c2.getName()));
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    64
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    65
        for (Class<?> c : classes) {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    66
            if (c.getSimpleName().startsWith("Lambda"))
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    67
                check(c);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    68
        }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    69
        if (errors > 0)
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    70
            throw new Exception(errors + " errors found");
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    71
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    72
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    73
    /** Check an individual test case. */
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    74
    void check(Class<?> c) throws Exception {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    75
        System.err.println("Checking " + c.getSimpleName());
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    76
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    77
        Expect expect = c.getAnnotation(Expect.class);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    78
        if (expect == null) {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    79
            error("@Expect not found for class " + c.getSimpleName());
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    80
            return;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    81
        }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    82
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    83
        ClassFile cf = ClassFile.read(getClass().getResource(c.getName() + ".class").openStream());
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    84
        Method m = getLambdaMethod(cf);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    85
        if (m == null) {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    86
            error("lambda method not found");
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    87
            return;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    88
        }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    89
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    90
        Code_attribute code = (Code_attribute) m.attributes.get(Attribute.Code);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    91
        if (code == null) {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    92
            error("Code attribute not found");
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    93
            return;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    94
        }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    95
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    96
        LocalVariableTable_attribute lvt =
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    97
                (LocalVariableTable_attribute) code.attributes.get(Attribute.LocalVariableTable);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    98
        if (lvt == null) {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
    99
            error("LocalVariableTable attribute not found");
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   100
            return;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   101
        }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   102
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   103
        Set<String> foundNames = new LinkedHashSet<>();
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   104
        for (LocalVariableTable_attribute.Entry e: lvt.local_variable_table) {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   105
            foundNames.add(cf.constant_pool.getUTF8Value(e.name_index));
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   106
        }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   107
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   108
        Set<String> expectNames = new LinkedHashSet<>(Arrays.asList(expect.value()));
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   109
        if (!foundNames.equals(expectNames)) {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   110
            Set<String> foundOnly = new LinkedHashSet<>(foundNames);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   111
            foundOnly.removeAll(expectNames);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   112
            for (String s: foundOnly)
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   113
                error("Unexpected name found: " + s);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   114
            Set<String> expectOnly = new LinkedHashSet<>(expectNames);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   115
            expectOnly.removeAll(foundNames);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   116
            for (String s: expectOnly)
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   117
                error("Expected name not found: " + s);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   118
        }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   119
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   120
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   121
    /** Get a method whose name begins "lambda$...". */
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   122
    Method getLambdaMethod(ClassFile cf) throws ConstantPoolException {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   123
        for (Method m: cf.methods) {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   124
            if (m.getName(cf.constant_pool).startsWith("lambda$"))
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   125
                return m;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   126
        }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   127
        return null;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   128
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   129
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   130
    /** Report an error. */
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   131
    void error(String msg) {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   132
        System.err.println("Error: " + msg);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   133
        errors++;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   134
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   135
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   136
    int errors;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   137
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   138
    /**
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   139
     * Annotation used to provide the set of names expected in the LVT attribute.
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   140
     */
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   141
    @Retention(RetentionPolicy.RUNTIME)
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   142
    @interface Expect {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   143
        String[] value();
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   144
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   145
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   146
    /** Functional interface with nullary method. */
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   147
    interface Run0 {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   148
        public void run();
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   149
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   150
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   151
    /** Functional interface with 1-ary method. */
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   152
    interface Run1 {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   153
        public void run(int a0);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   154
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   155
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   156
    /** Functional interface with 2-ary method. */
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   157
    interface Run2 {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   158
        public void run(int a0, int a1);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   159
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   160
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   161
    /*
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   162
     * ---------- Test cases ---------------------------------------------------
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   163
     */
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   164
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   165
    @Expect({ "x" })
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   166
    static class Lambda_Args0_Local1 {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   167
        Run0 r = () -> { int x = 0; };
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   168
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   169
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   170
    @Expect({ "x", "this" })
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   171
    static class Lambda_Args0_Local1_this {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   172
        int v;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   173
        Run0 r = () -> { int x = v; };
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   174
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   175
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   176
    @Expect({ "a" })
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   177
    static class Lambda_Args1_Local0 {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   178
        Run1 r = (a) -> { };
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   179
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   180
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   181
    @Expect({ "a", "x" })
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   182
    static class Lambda_Args1_Local1 {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   183
        Run1 r = (a) -> { int x = a; };
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   184
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   185
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   186
    @Expect({ "a", "x" })
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   187
    static class Lambda_Args1_Local1_Captured1 {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   188
        void m() {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   189
            int v = 0;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   190
            Run1 r = (a) -> { int x = a + v; };
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   191
        }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   192
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   193
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   194
    @Expect({ "a1", "a2", "x1", "x2", "this" })
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   195
    static class Lambda_Args2_Local2_Captured2_this {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   196
        int v;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   197
        void m() {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   198
            int v1 = 0;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   199
            int v2 = 0;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   200
            Run2 r = (a1, a2) -> {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   201
                int x1 = a1 + v1 + v;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   202
                int x2 = a2 + v2 + v;
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   203
            };
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   204
        }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   205
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   206
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   207
    @Expect({ "e" })
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   208
    static class Lambda_Try_Catch {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   209
        private static Runnable asUncheckedRunnable(Closeable c) {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   210
            return () -> {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   211
                try {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   212
                    c.close();
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   213
                } catch (IOException e) {
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   214
                   throw new UncheckedIOException(e);
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   215
                }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   216
            };
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   217
        }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   218
    }
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   219
}
02dc78554e0c 8026749: Missing LV table in lambda bodies
jjg
parents:
diff changeset
   220