langtools/test/tools/javap/T8032819.java
author katleman
Thu, 21 Aug 2014 14:16:14 -0700
changeset 25878 6d561031123e
parent 22695 a290c74925d7
child 30730 d3ce7619db2c
permissions -rw-r--r--
Added tag jdk9-b27 for changeset 98ce0879ab4c
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
/*
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
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
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    28
 * @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
    29
 * @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
    30
 */
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
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
    33
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
    34
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    35
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
    36
    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
    37
        int f1;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    38
        int f2;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    39
    }
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
    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
    42
        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
    43
    }
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
    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
    46
        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
    47
        test(clazz);
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, "-c");
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, "-l");
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", "-c");
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, "-v");
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", "-c");
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", "-l");
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", "-c");
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    55
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    56
        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
    57
            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
    58
    }
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
    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
    61
    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
    62
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    63
    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
    64
        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
    65
        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
    66
        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
    67
        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
    68
        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
    69
        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
    70
        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
    71
        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
    72
        pw.close();
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    73
        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
    74
        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
    75
            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
    76
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    77
        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
    78
        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
    79
        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
    80
            count++;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    81
            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
    82
        }
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
        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
    85
            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
    86
    }
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
    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
    89
        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
    90
        errors++;
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    91
    }
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
    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
    94
}
a290c74925d7 8032819: Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
jjg
parents:
diff changeset
    95