langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java
author jlahoda
Wed, 23 Oct 2013 07:50:04 +0200
changeset 21492 e7c8a164d7bd
parent 21489 langtools/test/tools/javac/T8019486/WrongLVTForLambdaTest.java@018e34d4045f
permissions -rw-r--r--
8026508: Invokedynamic instructions don't get line number table entries Summary: Setting or correcting positions for many trees produced by LambdaToMethod. Reviewed-by: vromero, rfield
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
     1
/*
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
     4
 *
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    10
 *
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    15
 * accompanied this code).
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    16
 *
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    20
 *
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    23
 * questions.
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    24
 */
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    25
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    26
/*
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    27
 * @test
21492
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    28
 * @bug 8019486 8026861
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    29
 * @summary javac, generates erroneous LVT for a test case with lambda code
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    30
 * @library /tools/javac/lib
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    31
 * @build ToolBox
21492
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    32
 * @run main WrongLNTForLambdaTest
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    33
 */
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    34
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    35
import java.io.File;
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    36
import java.nio.file.Paths;
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    37
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    38
import com.sun.tools.classfile.ClassFile;
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    39
import com.sun.tools.classfile.Code_attribute;
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    40
import com.sun.tools.classfile.LineNumberTable_attribute;
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    41
import com.sun.tools.classfile.Method;
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    42
import com.sun.tools.javac.util.Assert;
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    43
21492
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    44
public class WrongLNTForLambdaTest {
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    45
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    46
    static final String testSource =
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    47
    /* 01 */        "import java.util.List;\n" +
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    48
    /* 02 */        "import java.util.Arrays;\n" +
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    49
    /* 03 */        "import java.util.stream.Collectors;\n" +
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    50
    /* 04 */        "\n" +
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    51
    /* 05 */        "public class Foo {\n" +
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    52
    /* 06 */        "    void bar(int value) {\n" +
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    53
    /* 07 */        "        final List<Integer> numbers = Arrays.asList(1, 2, 3);\n" +
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    54
    /* 08 */        "        final List<Integer> numbersPlusOne = \n" +
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    55
    /* 09 */        "             numbers.stream().map(number -> number / 1).collect(Collectors.toList());\n" +
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    56
    /* 10 */        "    }\n" +
21492
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    57
    /* 11 */        "    void variablesInLambdas(int value) {\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    58
    /* 12 */        "        Runnable r1 = () -> {\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    59
    /* 13 */        "            int i  = value;\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    60
    /* 14 */        "            class FooBar<T extends CharSequence> {\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    61
    /* 15 */        "                public void run() {\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    62
    /* 16 */        "                    T t = null;\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    63
    /* 17 */        "                }\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    64
    /* 18 */        "            }\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    65
    /* 19 */        "        };\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    66
    /* 20 */        "        Runnable r2 = () -> System.err.println(1);\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    67
    /* 21 */        "        Runnable r3 = (Runnable & java.io.Serializable) this::foo;\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    68
    /* 22 */        "        Runnable r4 = super :: notify;\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    69
    /* 23 */        "    }\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    70
    /* 24 */        "    private void foo() {}\n" +
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    71
    /* 25 */        "}";
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    72
21492
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    73
    static final int[][] simpleLambdaExpectedLNT = {
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    74
    //  {line-number, start-pc},
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    75
        {9,           0},       //number -> number / 1
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    76
    };
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
    77
21492
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    78
    static final int[][] lambdaWithVarsExpectedLNT = {
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    79
    //  {line-number, start-pc},
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    80
        {13,           0},       //number -> number / 1
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    81
        {19,           2},       //number -> number / 1
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    82
    };
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    83
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    84
    static final int[][] insideLambdaWithVarsExpectedLNT = {
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    85
    //  {line-number, start-pc},
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    86
        {16,           0},       //number -> number / 1
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    87
        {17,           2},       //number -> number / 1
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    88
    };
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    89
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    90
    static final int[][] lambdaVoid2VoidExpectedLNT = {
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    91
    //  {line-number, start-pc},
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    92
        {20,           0},       //number -> number / 1
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    93
    };
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    94
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    95
    static final int[][] deserializeExpectedLNT = {
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    96
    //  {line-number, start-pc},
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    97
        {05,           0},       //number -> number / 1
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    98
    };
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
    99
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   100
    static final int[][] lambdaBridgeExpectedLNT = {
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   101
    //  {line-number, start-pc},
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   102
        {22,           0},       //number -> number / 1
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   103
    };
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   104
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   105
    public static void main(String[] args) throws Exception {
21492
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   106
        new WrongLNTForLambdaTest().run();
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   107
    }
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   108
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   109
    void run() throws Exception {
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   110
        compileTestClass();
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   111
        checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
21492
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   112
                "Foo.class").toUri()), "lambda$bar$0", simpleLambdaExpectedLNT);
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   113
        checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   114
                "Foo.class").toUri()), "lambda$variablesInLambdas$1", lambdaWithVarsExpectedLNT);
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   115
        checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   116
                "Foo$1FooBar.class").toUri()), "run", insideLambdaWithVarsExpectedLNT);
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   117
        checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   118
                "Foo.class").toUri()), "lambda$variablesInLambdas$2", lambdaVoid2VoidExpectedLNT);
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   119
        checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   120
                "Foo.class").toUri()), "$deserializeLambda$", deserializeExpectedLNT);
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   121
        checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   122
                "Foo.class").toUri()), "lambda$MR$variablesInLambdas$notify$8bc4f5bd$1", lambdaBridgeExpectedLNT);
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   123
    }
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   124
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   125
    void compileTestClass() throws Exception {
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   126
        ToolBox.JavaToolArgs javacSuccessArgs =
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   127
                new ToolBox.JavaToolArgs().setSources(testSource);
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   128
        ToolBox.javac(javacSuccessArgs);
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   129
    }
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   130
21492
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   131
    void checkClassFile(final File cfile, String methodToFind, int[][] expectedLNT) throws Exception {
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   132
        ClassFile classFile = ClassFile.read(cfile);
21492
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   133
        boolean methodFound = false;
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   134
        for (Method method : classFile.methods) {
21492
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   135
            if (method.getName(classFile.constant_pool).equals(methodToFind)) {
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   136
                methodFound = true;
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   137
                Code_attribute code = (Code_attribute) method.attributes.get("Code");
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   138
                LineNumberTable_attribute lnt =
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   139
                        (LineNumberTable_attribute) code.attributes.get("LineNumberTable");
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   140
                Assert.check(lnt.line_number_table_length == expectedLNT.length,
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   141
                        "The LineNumberTable found has a length different to the expected one");
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   142
                int i = 0;
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   143
                for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) {
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   144
                    Assert.check(entry.line_number == expectedLNT[i][0] &&
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   145
                            entry.start_pc == expectedLNT[i][1],
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   146
                            "LNT entry at pos " + i + " differ from expected." +
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   147
                            "Found " + entry.line_number + ":" + entry.start_pc +
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   148
                            ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]);
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   149
                    i++;
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   150
                }
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   151
            }
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   152
        }
21492
e7c8a164d7bd 8026508: Invokedynamic instructions don't get line number table entries
jlahoda
parents: 21489
diff changeset
   153
        Assert.check(methodFound, "The seek method was not found");
19487
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   154
    }
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   155
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   156
    void error(String msg) {
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   157
        throw new AssertionError(msg);
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   158
    }
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   159
9097d88f5e1f 8019486: javac, generates erroneous LVT for a test case with lambda code
vromero
parents:
diff changeset
   160
}