langtools/test/tools/javac/warnings/VerifyLintDescriptions.java
author jjg
Thu, 08 Dec 2016 16:52:38 -0800
changeset 42496 49cd6effe616
parent 36526 3b41f1c69604
child 44573 245bb4e6f983
permissions -rw-r--r--
8170953: CheckResourceKeys tests should declare the resource package to be open Reviewed-by: mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
     1
/*
42496
49cd6effe616 8170953: CheckResourceKeys tests should declare the resource package to be open
jjg
parents: 36526
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
     4
 *
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
     8
 *
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    13
 * accompanied this code).
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    14
 *
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    18
 *
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    21
 * questions.
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    22
 */
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    23
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    24
/**
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    25
 * @test
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    26
 * @bug 8033961
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    27
 * @summary Verify that all LintCategories have their descriptions filled.
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 23114
diff changeset
    28
 * @modules jdk.compiler/com.sun.tools.javac.code
42496
49cd6effe616 8170953: CheckResourceKeys tests should declare the resource package to be open
jjg
parents: 36526
diff changeset
    29
 *          jdk.compiler/com.sun.tools.javac.resources:open
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 23114
diff changeset
    30
 *          jdk.compiler/com.sun.tools.javac.util
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    31
 */
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    32
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 30730
diff changeset
    33
import java.lang.reflect.Layer;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 30730
diff changeset
    34
import java.lang.reflect.Module;
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    35
import java.util.ArrayList;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    36
import java.util.List;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    37
import java.util.Locale;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    38
import java.util.MissingResourceException;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    39
import java.util.ResourceBundle;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    40
import com.sun.tools.javac.code.Lint.LintCategory;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    41
import com.sun.tools.javac.util.Log.PrefixKind;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    42
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    43
public class VerifyLintDescriptions {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    44
    public static void main(String... args) {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 30730
diff changeset
    45
        Layer boot = Layer.boot();
3b41f1c69604 8142968: Module System implementation
alanb
parents: 30730
diff changeset
    46
        Module jdk_compiler = boot.findModule("jdk.compiler").get();
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    47
        ResourceBundle b = ResourceBundle.getBundle("com.sun.tools.javac.resources.javac",
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 30730
diff changeset
    48
                                                    Locale.US,
3b41f1c69604 8142968: Module System implementation
alanb
parents: 30730
diff changeset
    49
                                                    jdk_compiler);
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    50
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    51
        List<String> missing = new ArrayList<>();
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    52
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    53
        for (LintCategory lc : LintCategory.values()) {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    54
            try {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    55
                b.getString(PrefixKind.JAVAC.key("opt.Xlint.desc." + lc.option));
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    56
            } catch (MissingResourceException ex) {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    57
                missing.add(lc.option);
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    58
            }
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    59
        }
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    60
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    61
        if (!missing.isEmpty()) {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    62
            throw new UnsupportedOperationException("Lints that are missing description: " + missing);
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    63
        }
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    64
    }
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    65
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    66
}