jdk

Форк
0
/
IsSupportedOptionTest.java 
79 строк · 2.7 Кб
1
/*
2
 * Copyright (c) 2017, 2018, 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 8189782 8210555
27
 * @summary Test for isSupportedOption
28
 * @modules java.compiler
29
 *          jdk.compiler
30
 * @run main IsSupportedOptionTest
31
 */
32

33
import javax.tools.JavaCompiler;
34
import javax.tools.ToolProvider;
35

36
/**
37
 * Tests for JavaCompiler.isSupportedOption method.
38
 */
39
public class IsSupportedOptionTest {
40
    public static void main(String... args) throws Exception {
41
        new IsSupportedOptionTest().run();
42
    }
43

44
    public void run() throws Exception {
45
        JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
46
        check(tool, "-source", 1);
47
        check(tool, "--source", 1);
48
        check(tool, "-target", 1);
49
        check(tool, "--target", 1);
50
        check(tool, "--add-modules", 1);
51
        check(tool, "-verbose", 0);
52
        check(tool, "-proc:none", 0);
53
        check(tool, "-Xlint", 0);
54
        check(tool, "-Xlint:unchecked", 0);
55
        check(tool, "-Xdoclint", 0);
56
        check(tool, "-Xdoclint:stats", 0);
57
        check(tool, "-Xdoclint/package:foo", 0);
58
        check(tool, "--debug=any", 1);
59
        check(tool, "-g", 0);
60
        check(tool, "-g:vars", 0);
61
        check(tool, "-g:none", 0);
62
        check(tool, "-ZZZ", -1);
63
        check(tool, "-Afoobar", 0);
64

65
        try {
66
            check(tool, null, -1);
67
            throw new AssertionError("null was accepted without exception");
68
        } catch (NullPointerException e) {
69
        }
70
    }
71

72
    private void check(JavaCompiler tool, String option, int numArgs) {
73
        System.err.println("check " + option);
74
        int n = tool.isSupportedOption(option);
75
        if (n != numArgs) {
76
            throw new AssertionError("unexpected result for option: " + option + ": " + n);
77
        }
78
    }
79
}
80

81

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

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

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

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