2
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
27
* @summary javap -XDdetail:source behaves badly if source not available.
28
* @modules jdk.compiler
29
* jdk.jdeps/com.sun.tools.javap
34
public class T6980017 {
35
public static void main(String... args) throws Exception {
39
void run() throws Exception {
47
StringWriter sw = new StringWriter();
48
PrintWriter pw = new PrintWriter(sw);
49
int rc = com.sun.tools.javap.Main.run(args, pw);
52
error("Unexpected exit code: " + rc);
54
boolean foundBlankSourceLine = false;
55
boolean foundNoSourceLine = false;
56
for (String line: sw.toString().split("[\r\n]+")) {
57
System.err.println(line);
58
if (line.contains("Source code not available"))
59
foundNoSourceLine = true;
60
if (line.matches("\\s*\\( *[0-9]+\\)\\s*"))
61
foundBlankSourceLine = true;
64
if (foundBlankSourceLine)
65
error("found blank source lines");
67
if (!foundNoSourceLine)
68
error("did not find \"Source code not available\" message");
71
throw new Exception(errors + " errors occurred");
74
void error(String msg) {
75
System.err.println(msg);