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