jdk

Форк
0
/
T6980017.java 
80 строк · 2.5 Кб
1
/*
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.
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 6980017
27
 * @summary javap -XDdetail:source behaves badly if source not available.
28
 * @modules jdk.compiler
29
 *          jdk.jdeps/com.sun.tools.javap
30
 */
31

32
import java.io.*;
33

34
public class T6980017 {
35
    public static void main(String... args) throws Exception {
36
        new T6980017().run();
37
    }
38

39
    void run() throws Exception {
40

41
        String[] args = {
42
            "-v",
43
            "-XDdetails:source",
44
            "java.lang.Object"
45
        };
46

47
        StringWriter sw = new StringWriter();
48
        PrintWriter pw = new PrintWriter(sw);
49
        int rc = com.sun.tools.javap.Main.run(args, pw);
50
        pw.close();
51
        if (rc != 0)
52
            error("Unexpected exit code: " + rc);
53

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;
62
        }
63

64
        if (foundBlankSourceLine)
65
            error("found blank source lines");
66

67
        if (!foundNoSourceLine)
68
            error("did not find \"Source code not available\" message");
69

70
        if (errors > 0)
71
            throw new Exception(errors + " errors occurred");
72
    }
73

74
    void error(String msg) {
75
        System.err.println(msg);
76
        errors++;
77
    }
78

79
    int errors;
80
}
81

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.