langtools/test/tools/javap/T8032819.java
author akulyakh
Thu, 21 May 2015 11:41:04 -0700
changeset 30730 d3ce7619db2c
parent 22695 a290c74925d7
child 30846 2b3f379840f0
permissions -rw-r--r--
8076543: Add @modules as needed to the langtools tests Reviewed-by: jjg, shurailine
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22695
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 22695
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
22695
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
     4
 *
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
     8
 *
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    13
 * accompanied this code).
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    14
 *
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    18
 *
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    21
 * questions.
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    22
 */
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    23
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    24
/*
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    25
 * @test
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    26
 * @bug 8032819
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    27
 * @summary Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 22695
diff changeset
    28
 * @modules jdk.compiler
22695
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    29
 * @compile -g T8032819.java
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    30
 * @run main T8032819
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    31
 */
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    32
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    33
import java.io.*;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    34
import java.util.*;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    35
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    36
public class T8032819 {
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    37
    static class Fields {
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    38
        int f1;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    39
        int f2;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    40
    }
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    41
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    42
    public static void main(String... args) throws Exception {
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    43
        new T8032819().run();
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    44
    }
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    45
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    46
    void run() throws Exception {
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    47
        Class<?> clazz = Fields.class;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    48
        test(clazz);
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    49
        test(clazz, "-c");
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    50
        test(clazz, "-l");
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    51
        test(clazz, "-l", "-c");
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    52
        test(clazz, "-v");
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    53
        test(clazz, "-v", "-c");
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    54
        test(clazz, "-v", "-l");
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    55
        test(clazz, "-v", "-l", "-c");
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    56
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    57
        if (errors > 0)
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    58
            throw new Exception(errors + " errors occurred");
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    59
    }
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    60
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    61
    static final String sep = System.getProperty("line.separator");
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    62
    static final String doubleBlankLine = sep + sep + sep;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    63
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    64
    void test(Class<?> clazz, String... opts) throws Exception {
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    65
        System.err.println("test " + Arrays.asList(opts));
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    66
        List<String> args = new ArrayList<String>();
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    67
        args.addAll(Arrays.asList(opts));
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    68
        args.addAll(Arrays.asList("-classpath", System.getProperty("test.classes")));
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    69
        args.add(clazz.getName());
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    70
        StringWriter sw = new StringWriter();
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    71
        PrintWriter pw = new PrintWriter(sw);
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    72
        int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw);
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    73
        pw.close();
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    74
        String out = sw.toString();
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    75
        if (rc != 0)
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    76
            throw new Exception("javap failed unexpectedly: rc=" + rc);
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    77
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    78
        int count = 0;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    79
        int i = out.indexOf(doubleBlankLine, 0);
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    80
        while (i != -1) {
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    81
            count++;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    82
            i = out.indexOf(doubleBlankLine, i + doubleBlankLine.length());
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    83
        }
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    84
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    85
        if (count > 0)
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    86
            error(count + " double blank lines found");
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    87
    }
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    88
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    89
    void error(String msg) {
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    90
        System.err.println("Error: " + msg);
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    91
        errors++;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    92
    }
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    93
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    94
    int errors = 0;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    95
}
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    96