langtools/test/tools/javac/T8152360/DeprecateJavahTest.java
author mcimadamore
Wed, 26 Oct 2016 15:41:25 +0100
changeset 41856 13a056e8f16e
parent 38605 72ca5671f3e6
permissions -rw-r--r--
8168774: Polymorhic signature method check crashes javac Summary: Check for polysig method assumes arity is greater than zero Reviewed-by: vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38605
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
     1
/*
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
     4
 *
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
     7
 * published by the Free Software Foundation.
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
     8
 *
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    13
 * accompanied this code).
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    14
 *
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    18
 *
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    21
 * questions.
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    22
 */
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    23
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    24
/*
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    25
 * @test
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    26
 * @bug 8152360
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    27
 * @summary deprecate javah
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    28
 * @library /tools/lib
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    29
 * @modules jdk.compiler/com.sun.tools.javac.api
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    30
 *          jdk.compiler/com.sun.tools.javac.main
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    31
 *          jdk.compiler/com.sun.tools.javah
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    32
 * @build toolbox.ToolBox toolbox.JavahTask
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    33
 * @run main DeprecateJavahTest
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    34
 */
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    35
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    36
import toolbox.JavahTask;
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    37
import toolbox.Task;
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    38
import toolbox.ToolBox;
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    39
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    40
public class DeprecateJavahTest {
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    41
    public static void main(String... args) throws Exception {
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    42
        new DeprecateJavahTest().run();
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    43
    }
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    44
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    45
    ToolBox tb = new ToolBox();
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    46
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    47
    void printDeprecationWarning() throws Exception {
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    48
        String output = new JavahTask(tb)
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    49
                .options("-version")
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    50
                .run()
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    51
                .writeAll()
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    52
                .getOutput(Task.OutputKind.DIRECT);
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    53
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    54
        if (!output.contains(
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    55
                "Warning: The javah tool is planned to be removed in the next major\n" +
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    56
                "JDK release. The tool has been superseded by the '-h' option added\n" +
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    57
                "to javac in JDK 8. Users are recommended to migrate to using the\n" +
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    58
                "javac '-h' option; see the javac man page for more information.")) {
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    59
            throw new Exception("test failed");
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    60
        }
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    61
    }
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    62
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    63
    void dontPrintDeprecationWarning() throws Exception {
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    64
        String output = new JavahTask(tb)
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    65
                .options("-version", "-XDsuppress-tool-removal-message")
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    66
                .run()
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    67
                .writeAll()
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    68
                .getOutput(Task.OutputKind.DIRECT);
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    69
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    70
        if (!output.startsWith("javah version")) {
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    71
            throw new Exception("test failed");
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    72
        }
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    73
    }
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    74
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    75
    void run() throws Exception {
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    76
        printDeprecationWarning();
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    77
        dontPrintDeprecationWarning();
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    78
    }
72ca5671f3e6 8152360: deprecate javah
vromero
parents:
diff changeset
    79
}