langtools/test/tools/javac/classfiles/attributes/lib/TestBase.java
author jjg
Fri, 04 Jul 2014 10:52:22 +0100
changeset 25434 823512a72660
parent 24223 90b07e33a49d
child 25845 14935053bb07
permissions -rw-r--r--
8042261: Implement classfile tests for Deprecated attribute. Reviewed-by: jjg, anazarov, shurailine
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 java.io.File;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    25
import java.io.IOException;
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    26
import java.io.PrintStream;
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    27
import java.util.*;
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    28
import java.util.function.Function;
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    29
import java.util.stream.Stream;
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    30
import javax.tools.*;
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    31
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    32
import static java.lang.String.format;
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    33
import static java.lang.System.lineSeparator;
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    34
import static java.util.Arrays.asList;
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    35
import static java.util.Collections.emptyList;
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    36
import static java.util.stream.Collectors.joining;
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    37
import static java.util.stream.Collectors.toList;
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    38
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    39
public class TestBase {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    40
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    41
    public static final String LINE_SEPARATOR = lineSeparator();
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    42
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    43
    private <S> InMemoryFileManager compile(
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    44
            List<String> options,
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    45
            Function<S, ? extends JavaFileObject> src2JavaFileObject,
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    46
            List<S> sources)
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    47
            throws IOException, CompilationException {
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    48
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    49
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    50
        List<? extends JavaFileObject> src = sources.stream()
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    51
                .map(src2JavaFileObject)
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    52
                .collect(toList());
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    53
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    54
        DiagnosticCollector<? super JavaFileObject> dc = new DiagnosticCollector<>();
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    55
        try (InMemoryFileManager fileManager
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    56
                     = new InMemoryFileManager(compiler.getStandardFileManager(null, null, null))) {
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    57
            JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, dc, options, null, src);
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    58
            boolean success = task.call();
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    59
            if (!success) {
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    60
                String errorMessage = dc.getDiagnostics().stream()
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    61
                        .map(Object::toString)
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    62
                        .collect(joining("\n"));
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    63
                throw new CompilationException("Compilation Error\n\n" + errorMessage);
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    64
            }
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    65
            return fileManager;
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    66
        }
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    67
    }
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    68
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    69
    public InMemoryFileManager compile(String... sources)
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    70
            throws IOException, CompilationException {
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    71
        return compile(emptyList(), sources);
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    72
    }
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    73
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    74
    /**
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    75
     * @param options - compiler options
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    76
     * @param sources
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    77
     * @return map where key is className, value is corresponding ClassFile.
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    78
     * @throws IOException
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    79
     */
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    80
    public InMemoryFileManager compile(List<String> options, String...sources)
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    81
            throws IOException, CompilationException {
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    82
        return compile(options, ToolBox.JavaSource::new, asList(sources));
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    83
    }
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    84
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    85
    public InMemoryFileManager compile(String[]... sources) throws IOException,
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    86
            CompilationException {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    87
        return compile(emptyList(), sources);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    88
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    89
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    90
    /**
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    91
     * @param options -  compiler options
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    92
     * @param sources - sources[i][0] - name of file, sources[i][1] - sources
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    93
     * @return map where key is className, value is corresponding ClassFile.
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    94
     * @throws IOException
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    95
     * @throws CompilationException
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
    96
     */
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    97
    public InMemoryFileManager compile(List<String> options, String[]...sources)
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    98
            throws IOException, CompilationException {
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
    99
        return compile(options, src -> new ToolBox.JavaSource(src[0], src[1]), asList(sources));
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   100
    }
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
    public void assertEquals(Object actual, Object expected, String message) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   103
        if (!Objects.equals(actual, expected))
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   104
            throw new AssertionFailedException(format("%s%nGot: %s, Expected: %s", message, actual, expected));
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   105
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   106
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   107
    public void assertNull(Object actual, String message) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   108
        assertEquals(actual, null, message);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   109
    }
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
    public void assertNotNull(Object actual, String message) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   112
        if (Objects.isNull(actual)) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   113
            throw new AssertionFailedException(message + " : Expected not null value");
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
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   116
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   117
    public void assertTrue(boolean actual, String message) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   118
        assertEquals(actual, true, message);
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
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   121
    public void assertFalse(boolean actual, String message) {
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   122
        assertEquals(actual, false, message);
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   123
    }
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   124
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   125
    public File getSourceDir() {
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   126
        return new File(System.getProperty("test.src", "."));
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   127
    }
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   128
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   129
    public File getClassDir() {
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   130
        return new File(System.getProperty("test.classes", TestBase.class.getResource(".").getPath()));
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   131
    }
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   132
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   133
    public File getSourceFile(String fileName) {
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   134
        return new File(getSourceDir(), fileName);
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   135
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   136
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   137
    public File getClassFile(String fileName) {
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   138
        return new File(getClassDir(), fileName);
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   139
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   140
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   141
    public File getClassFile(Class clazz) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   142
        return getClassFile(clazz.getName().replace(".", "/") + ".class");
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   143
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   144
25434
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   145
    public void echo(String message) {
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   146
        System.err.println(message.replace("\n", LINE_SEPARATOR));
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   147
    }
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   148
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   149
    public void printf(String template, Object...args) {
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   150
        System.err.printf(template, Stream.of(args)
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   151
                .map(Objects::toString)
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   152
                .map(m -> m.replace("\n", LINE_SEPARATOR))
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   153
                .collect(toList())
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   154
                .toArray());
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   155
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   156
    }
823512a72660 8042261: Implement classfile tests for Deprecated attribute.
jjg
parents: 24223
diff changeset
   157
24223
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   158
    public static class CompilationException extends Exception {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   159
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   160
        public CompilationException(String message) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   161
            super(message);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   162
        }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   163
    }
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
    public static class AssertionFailedException extends RuntimeException {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   166
        public AssertionFailedException(String message) {
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   167
            super(message);
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   168
        }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   169
    }
90b07e33a49d 8040097: Implement classfile tests for LocalVariableTable and LocalVariableTypeTable attribute.
anazarov
parents:
diff changeset
   170
}