langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTestBase.java
author anazarov
Thu, 24 Jul 2014 15:12:48 -0700
changeset 25845 14935053bb07
parent 25699 7ca97d2d0405
permissions -rw-r--r--
8050979: Provide javadoc for "framework" classes in langtools tests Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
     1
/*
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
     4
 *
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
     8
 *
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    13
 * accompanied this code).
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    14
 *
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    18
 *
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    21
 * questions.
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    22
 */
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    23
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    24
import com.sun.tools.classfile.*;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    25
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    26
import java.io.IOException;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    27
import java.lang.annotation.Repeatable;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    28
import java.lang.annotation.Retention;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    29
import java.lang.annotation.RetentionPolicy;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    30
import java.util.Collection;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    31
import java.util.HashMap;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    32
import java.util.List;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    33
import java.util.Map;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    34
import java.util.stream.Stream;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    35
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    36
import static java.lang.String.format;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    37
import static java.util.stream.Collectors.*;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    38
25845
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    39
/**
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    40
 * Base class for LocalVariableTable and LocalVariableTypeTable attributes tests.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    41
 * To add tests cases you should extend this class.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    42
 * Then implement {@link #getVariableTables} to get LocalVariableTable or LocalVariableTypeTable attribute.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    43
 * Then add method with local variables.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    44
 * Finally, annotate method with information about expected variables and their types
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    45
 * by several {@link LocalVariableTestBase.ExpectedLocals} annotations.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    46
 * To run test invoke {@link #test()} method.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    47
 * If there are variables with the same name, set different scopes for them.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    48
 *
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    49
 * @see #test()
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    50
 */
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    51
public abstract class LocalVariableTestBase extends TestBase {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    52
    public static final int DEFAULT_SCOPE = 0;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    53
    private final ClassFile classFile;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    54
    private final Class<?> clazz;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    55
25845
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    56
    /**
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    57
     * @param clazz class to test. Must contains annotated methods with expected results.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    58
     */
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    59
    public LocalVariableTestBase(Class<?> clazz) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    60
        this.clazz = clazz;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    61
        try {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    62
            this.classFile = ClassFile.read(getClassFile(clazz));
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    63
        } catch (IOException | ConstantPoolException e) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    64
            throw new IllegalArgumentException("Can't read classfile for specified class", e);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    65
        }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    66
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    67
25845
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    68
    protected abstract List<VariableTable> getVariableTables(Code_attribute codeAttribute);
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    69
25845
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    70
    /**
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    71
     * Finds expected variables with their type in VariableTable.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    72
     * Also does consistency checks, like variables from the same scope must point to different indexes.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
    73
     */
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    74
    public void test() throws IOException {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    75
        List<java.lang.reflect.Method> testMethods = Stream.of(clazz.getDeclaredMethods())
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    76
                .filter(m -> m.getAnnotationsByType(ExpectedLocals.class).length > 0)
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    77
                .collect(toList());
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    78
        int failed = 0;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    79
        for (java.lang.reflect.Method method : testMethods) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    80
            try {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    81
                Map<String, String> expectedLocals2Types = new HashMap<>();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    82
                Map<String, Integer> sig2scope = new HashMap<>();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    83
                for (ExpectedLocals anno : method.getDeclaredAnnotationsByType(ExpectedLocals.class)) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    84
                    expectedLocals2Types.put(anno.name(), anno.type());
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    85
                    sig2scope.put(anno.name() + "&" + anno.type(), anno.scope());
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    86
                }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    87
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    88
                test(method.getName(), expectedLocals2Types, sig2scope);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    89
            } catch (AssertionFailedException ex) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    90
                System.err.printf("Test %s failed.%n", method.getName());
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    91
                ex.printStackTrace();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    92
                failed++;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    93
            }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    94
        }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    95
        if (failed > 0)
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    96
            throw new RuntimeException(format("Failed %d out of %d. See logs.", failed, testMethods.size()));
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    97
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    98
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    99
    public void test(String methodName, Map<String, String> expectedLocals2Types, Map<String, Integer> sig2scope)
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   100
            throws IOException {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   101
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   102
        for (Method m : classFile.methods) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   103
            String mName = getString(m.name_index);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   104
            if (methodName.equals(mName)) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   105
                System.out.println("Testing local variable table in method " + mName);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   106
                Code_attribute code_attribute = (Code_attribute) m.attributes.get(Attribute.Code);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   107
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   108
                List<? extends VariableTable> variableTables = getVariableTables(code_attribute);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   109
                generalLocalVariableTableCheck(variableTables);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   110
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   111
                List<VariableTable.Entry> entries = variableTables.stream()
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   112
                        .flatMap(table -> table.entries().stream())
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   113
                        .collect(toList());
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   114
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   115
                generalEntriesCheck(entries, code_attribute);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   116
                assertIndexesAreUnique(entries, sig2scope);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   117
                checkNamesAndTypes(entries, expectedLocals2Types);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   118
                checkDoubleAndLongIndexes(entries, sig2scope, code_attribute.max_locals);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   119
            }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   120
        }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   121
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   122
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   123
    private void generalLocalVariableTableCheck(List<? extends VariableTable> variableTables) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   124
        for (VariableTable localTable : variableTables) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   125
            //only one per variable.
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   126
            assertEquals(localTable.localVariableTableLength(),
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   127
                    localTable.entries().size(), "Incorrect local variable table length");
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   128
            //attribute length is offset(line_number_table_length) + element_size*element_count
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   129
            assertEquals(localTable.attributeLength(),
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   130
                    2 + (5 * 2) * localTable.localVariableTableLength(), "Incorrect attribute length");
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   131
        }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   132
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   133
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   134
    private void generalEntriesCheck(List<VariableTable.Entry> entries, Code_attribute code_attribute) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   135
        for (VariableTable.Entry e : entries) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   136
            assertTrue(e.index() >= 0 && e.index() < code_attribute.max_locals,
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   137
                    "Index " + e.index() + " out of variable array. Size of array is " + code_attribute.max_locals);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   138
            assertTrue(e.startPC() >= 0, "StartPC is less then 0. StartPC = " + e.startPC());
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   139
            assertTrue(e.length() >= 0, "Length is less then 0. Length = " + e.length());
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   140
            assertTrue(e.startPC() + e.length() <= code_attribute.code_length,
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   141
                    format("StartPC+Length > code length.%n" +
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   142
                            "%s%n" +
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   143
                            "code_length = %s"
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   144
                            , e, code_attribute.code_length));
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   145
        }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   146
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   147
25699
7ca97d2d0405 8050319: LocalVariableTestBase has unexpected dependency on LocalVariableTableTest
ksrini
parents: 24223
diff changeset
   148
    private void checkNamesAndTypes(List<VariableTable.Entry> entries,
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   149
                                    Map<String, String> expectedLocals2Types) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   150
        Map<String, List<String>> actualNames2Types = entries.stream()
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   151
                .collect(
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   152
                        groupingBy(VariableTable.Entry::name,
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   153
                                mapping(VariableTable.Entry::type, toList())));
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   154
        for (Map.Entry<String, String> name2type : expectedLocals2Types.entrySet()) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   155
            String name = name2type.getKey();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   156
            String type = name2type.getValue();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   157
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   158
            assertTrue(actualNames2Types.containsKey(name),
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   159
                    format("There is no record for local variable %s%nEntries: %s", name, entries));
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   160
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   161
            assertTrue(actualNames2Types.get(name).contains(type),
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   162
                    format("Types are different for local variable %s%nExpected type: %s%nActual type: %s",
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   163
                            name, type, actualNames2Types.get(name)));
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   164
        }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   165
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   166
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   167
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   168
    private void assertIndexesAreUnique(Collection<VariableTable.Entry> entries, Map<String, Integer> scopes) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   169
        //check every scope separately
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   170
        Map<Object, List<VariableTable.Entry>> entriesByScope = groupByScope(entries, scopes);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   171
        for (Map.Entry<Object, List<VariableTable.Entry>> mapEntry : entriesByScope.entrySet()) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   172
            mapEntry.getValue().stream()
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   173
                    .collect(groupingBy(VariableTable.Entry::index))
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   174
                    .entrySet()
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   175
                    .forEach(e ->
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   176
                            assertTrue(e.getValue().size() == 1,
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   177
                                    "Multiple variables point to the same index in common scope. " + e.getValue()));
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   178
        }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   179
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   180
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   181
25699
7ca97d2d0405 8050319: LocalVariableTestBase has unexpected dependency on LocalVariableTableTest
ksrini
parents: 24223
diff changeset
   182
    private void checkDoubleAndLongIndexes(Collection<VariableTable.Entry> entries,
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   183
                                           Map<String, Integer> scopes, int maxLocals) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   184
        //check every scope separately
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   185
        Map<Object, List<VariableTable.Entry>> entriesByScope = groupByScope(entries, scopes);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   186
        for (List<VariableTable.Entry> entryList : entriesByScope.values()) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   187
            Map<Integer, VariableTable.Entry> index2Entry = entryList.stream()
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   188
                    .collect(toMap(VariableTable.Entry::index, e -> e));
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   189
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   190
            entryList.stream()
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   191
                    .filter(e -> "J".equals(e.type()) || "D".equals(e.type()))
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   192
                    .forEach(e -> {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   193
                        assertTrue(e.index() + 1 < maxLocals,
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   194
                                format("Index %s is out of variable array. Long and double occupy 2 cells." +
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   195
                                        " Size of array is %d", e.index() + 1, maxLocals));
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   196
                        assertTrue(!index2Entry.containsKey(e.index() + 1),
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   197
                                format("An entry points to the second cell of long/double entry.%n%s%n%s", e,
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   198
                                        index2Entry.get(e.index() + 1)));
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   199
                    });
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   200
        }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   201
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   202
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   203
    private Map<Object, List<VariableTable.Entry>> groupByScope(
25699
7ca97d2d0405 8050319: LocalVariableTestBase has unexpected dependency on LocalVariableTableTest
ksrini
parents: 24223
diff changeset
   204
            Collection<VariableTable.Entry> entries, Map<String, Integer> scopes) {
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   205
        return entries.stream().collect(groupingBy(e -> scopes.getOrDefault(e.name() + "&" + e.type(), DEFAULT_SCOPE)));
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   206
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   207
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   208
    protected String getString(int i) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   209
        try {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   210
            return classFile.constant_pool.getUTF8Info(i).value;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   211
        } catch (ConstantPool.InvalidIndex | ConstantPool.UnexpectedEntry ex) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   212
            ex.printStackTrace();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   213
            throw new AssertionFailedException("Issue while reading constant pool");
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   214
        }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   215
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   216
25845
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   217
    /**
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   218
     * LocalVariableTable and LocalVariableTypeTable are similar.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   219
     * VariableTable interface is introduced to test this attributes in the same way without code duplication.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   220
     */
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   221
    interface VariableTable {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   222
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   223
        int localVariableTableLength();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   224
25699
7ca97d2d0405 8050319: LocalVariableTestBase has unexpected dependency on LocalVariableTableTest
ksrini
parents: 24223
diff changeset
   225
        List<VariableTable.Entry> entries();
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   226
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   227
        int attributeLength();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   228
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   229
        interface Entry {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   230
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   231
            int index();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   232
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   233
            int startPC();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   234
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   235
            int length();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   236
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   237
            String name();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   238
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   239
            String type();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   240
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   241
            default String dump() {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   242
                return format("Entry{" +
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   243
                        "%n    name    = %s" +
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   244
                        "%n    type    = %s" +
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   245
                        "%n    index   = %d" +
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   246
                        "%n    startPC = %d" +
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   247
                        "%n    length  = %d" +
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   248
                        "%n}", name(), type(), index(), startPC(), length());
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   249
            }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   250
        }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   251
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   252
25845
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   253
    /**
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   254
     * Used to store expected results in sources
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   255
     */
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   256
    @Retention(RetentionPolicy.RUNTIME)
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   257
    @Repeatable(Container.class)
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   258
    @interface ExpectedLocals {
25845
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   259
        /**
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   260
         * @return name of a local variable
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   261
         */
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   262
        String name();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   263
25845
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   264
        /**
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   265
         * @return type of local variable in the internal format.
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   266
         */
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   267
        String type();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   268
25845
14935053bb07 8050979: Provide javadoc for "framework" classes in langtools tests
anazarov
parents: 25699
diff changeset
   269
        //variables from different scopes can share the local variable table index and/or name.
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   270
        int scope() default DEFAULT_SCOPE;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   271
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   272
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   273
    @Retention(RetentionPolicy.RUNTIME)
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   274
    @interface Container {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   275
        ExpectedLocals[] value();
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   276
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   277
}