langtools/test/tools/javac/MethodParameters/Tester.java
author mnunez
Thu, 17 Oct 2013 13:27:36 +0200
changeset 21044 ffba9cdeff1a
parent 18000 5d29ce00a7a2
child 21482 21e66f272f98
permissions -rw-r--r--
8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final Reviewed-by: jjg, jfranck
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
     1
/*
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
     4
 *
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
     8
 *
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    13
 * accompanied this code).
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    14
 *
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    18
 *
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    21
 * questions.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    22
 */
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    23
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    24
import java.io.*;
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    25
import java.lang.reflect.Constructor;
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    26
import java.nio.charset.StandardCharsets;
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    27
import java.nio.file.Files;
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    28
import java.util.ArrayList;
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    29
import java.util.Arrays;
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    30
import java.util.Collections;
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    31
import java.util.List;
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    32
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    33
/**
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    34
 * Test driver for MethodParameters testing.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    35
 * <p>
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    36
 * The intended use of this driver is to run it, giving the name of
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    37
 * a single class compiled with -parameters as argument. The driver
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    38
 * will test the specified class, and any nested classes it finds.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    39
 * <p>
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    40
 * Each class is tested in two way. By refelction, and by directly
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    41
 * checking MethodParameters attributes in the classfile. The checking
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    42
 * is done using two visitor classes {@link ClassFileVisitor} and
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    43
 * {@link ReflectionVisitor}.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    44
 * <p>
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    45
 * The {@code ReflectionVisitor} test logically belongs with library tests.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    46
 * we wish to reuse the same test-cases, so both test are committed together,
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    47
 * under langtools. The tests, may be duplicated in the jdk repository.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    48
 */
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    49
public class Tester {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    50
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    51
    final static File classesdir = new File(System.getProperty("test.classes", "."));
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    52
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    53
    private String classname;
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    54
    private File[] files;
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    55
    private File refFile;
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    56
    private int errors;
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    57
    private int warnings;
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    58
    private int diffGolden;
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    59
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    60
    /**
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    61
     * The visitor classes that does the actual checking are referenced
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    62
     * statically, to force compilations, without having to reference
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    63
     * them in individual test cases.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    64
     * <p>
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    65
     * This makes it easy to change the set of visitors, without
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    66
     * complicating the design with dynamic discovery and compilation
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    67
     * of visitor classes.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    68
     */
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    69
    static final Class visitors[] = {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    70
        ClassFileVisitor.class,
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    71
        ReflectionVisitor.class
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    72
    };
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    73
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    74
    /**
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    75
     * Test-driver expect a single classname as argument.
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    76
     */
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    77
    public static void main(String... args) throws Exception {
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    78
        if (args.length != 2) {
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    79
            throw new Error("A single class name and a golden file are expected as argument");
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    80
        }
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    81
        String testSrc = System.getProperty("test.src");
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    82
        String testName = args[0];
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    83
        String testGoldenFile = args[1];
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    84
        final String pattern = testName + ".*\\.class";
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    85
        File refFile = new File(testSrc, testGoldenFile);
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    86
        File[] files = classesdir.listFiles(new FileFilter() {
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    87
                public boolean accept(File f) {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    88
                    return f.getName().matches(pattern);
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    89
                }
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    90
            });
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    91
        if (files.length == 0) {
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    92
            File file = new File(classesdir, testName + ".class");
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    93
            throw new Error(file.getPath() + " not found");
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    94
        }
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    95
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    96
        new Tester(testName, files, refFile).run();
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    97
    }
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
    98
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
    99
    public Tester(String name, File[] files, File refFile) {
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   100
        this.classname = name;
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   101
        this.files = files;
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   102
        this.refFile = refFile;
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   103
    }
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   104
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   105
    void run() throws Exception {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   106
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   107
        // Test with each visitor
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   108
        for (Class<Visitor> vclass : visitors) {
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   109
            boolean compResult = false;
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   110
            try {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   111
                String vname = vclass.getName();
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   112
                Constructor c = vclass.getConstructor(Tester.class);
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   113
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   114
                info("\nRun " + vname + " for " + classname + "\n");
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   115
                StringBuilder sb = new StringBuilder();
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   116
                for (File f : files) {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   117
                    String fname = f.getName();
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   118
                    fname = fname.substring(0, fname.length() - 6);
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   119
                    Visitor v = (Visitor) c.newInstance(this);
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   120
                    try {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   121
                        v.visitClass(fname, f,  sb);
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   122
                    } catch(Exception e) {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   123
                        error("Uncaught exception in visitClass()");
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   124
                        e.printStackTrace();
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   125
                    }
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   126
                }
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   127
                String output = sb.toString();
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   128
                info(output);
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   129
                compResult = compareOutput(refFile, output);
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   130
            } catch(ReflectiveOperationException e) {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   131
                warn("Class " + vclass.getName() + " ignored, not a Visitor");
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   132
                continue;
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   133
            }
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   134
            if (!compResult) {
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   135
                diffGolden++;
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   136
                error("The output from " + vclass.getName() + " did not match golden file.");
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   137
        }
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   138
        }
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   139
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   140
        if (0 != diffGolden)
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   141
            throw new Exception("Test output is not equal with golden file.");
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   142
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   143
        if(0 != warnings)
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   144
                System.err.println("Test generated " + warnings + " warnings");
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   145
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   146
        if(0 != errors)
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   147
            throw new Exception("Tester test failed with " +
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   148
                                errors + " errors");
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   149
    }
21044
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   150
    // Check if test output matches the golden file.
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   151
    boolean compareOutput(File refFile, String sb)
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   152
            throws FileNotFoundException, IOException {
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   153
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   154
        List<String> refFileList = Files.readAllLines(refFile.toPath(), StandardCharsets.UTF_8);
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   155
        List<String> sbList = Arrays.asList(sb.split(System.getProperty("line.separator")));
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   156
        // Check if test output contains unexpected lines or is missing expected lines.
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   157
        List<String> sbOnly = new ArrayList<String>(sbList);
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   158
        sbOnly.removeAll(refFileList);
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   159
        for (String line: sbOnly)
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   160
            error("unexpected line found: " + line);
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   161
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   162
        List<String> refOnly = new ArrayList<String>(refFileList);
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   163
        refOnly.removeAll(sbList);
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   164
        for (String line: refOnly)
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   165
            error("expected line not found: " + line);
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   166
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   167
        return sbOnly.isEmpty() && refOnly.isEmpty();
ffba9cdeff1a 8015372: Update tests for Method Parameter Reflection API to check whether a parameter is final
mnunez
parents: 18000
diff changeset
   168
    }
16307
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   169
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   170
    abstract static  class Visitor {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   171
        Tester tester;
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   172
        File classesdir;
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   173
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   174
        public Visitor(Tester tester) {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   175
            this.tester = tester;
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   176
        }
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   177
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   178
        abstract void visitClass(final String classname, final File  cfile,
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   179
                final StringBuilder sb) throws Exception;
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   180
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   181
        public void error(String msg) {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   182
            tester.error(msg);
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   183
        }
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   184
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   185
        public void warn(String msg) {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   186
            tester.warn(msg);
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   187
        }
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   188
    }
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   189
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   190
    void error(String msg) {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   191
        System.err.println("Error: " + msg);
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   192
        errors++;
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   193
    }
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   194
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   195
    void warn(String msg) {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   196
        System.err.println("Warning: " + msg);
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   197
        warnings++;
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   198
    }
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   199
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   200
    void info(String msg) {
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   201
        System.out.println(msg);
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   202
    }
3027c91f329a 8006582: Test for parameter names feature
strarup
parents:
diff changeset
   203
}