langtools/test/tools/javac/warnings/VerifyLintDescriptions.java
author akulyakh
Thu, 21 May 2015 11:41:04 -0700
changeset 30730 d3ce7619db2c
parent 23114 7fe55d6324d5
child 36526 3b41f1c69604
permissions -rw-r--r--
8076543: Add @modules as needed to the langtools tests Reviewed-by: jjg, shurailine
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 23114
diff changeset
     2
 * Copyright (c) 2014, 2015, 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
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 23114
diff changeset
    29
 *          jdk.compiler/com.sun.tools.javac.util
23114
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    30
 */
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
import java.util.ArrayList;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    33
import java.util.List;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    34
import java.util.Locale;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    35
import java.util.MissingResourceException;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    36
import java.util.ResourceBundle;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    37
import com.sun.tools.javac.code.Lint.LintCategory;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    38
import com.sun.tools.javac.util.Log.PrefixKind;
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    39
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    40
public class VerifyLintDescriptions {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    41
    public static void main(String... args) {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    42
        ResourceBundle b = ResourceBundle.getBundle("com.sun.tools.javac.resources.javac",
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    43
                                                    Locale.US);
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    44
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    45
        List<String> missing = new ArrayList<>();
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    46
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    47
        for (LintCategory lc : LintCategory.values()) {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    48
            try {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    49
                b.getString(PrefixKind.JAVAC.key("opt.Xlint.desc." + lc.option));
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    50
            } catch (MissingResourceException ex) {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    51
                missing.add(lc.option);
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
        }
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    54
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    55
        if (!missing.isEmpty()) {
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    56
            throw new UnsupportedOperationException("Lints that are missing description: " + missing);
7fe55d6324d5 8033961: Formatting of -Xlint: command line help
jlahoda
parents:
diff changeset
    57
        }
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
}