langtools/test/tools/javah/T4942232/MissingParamClassTest.java
changeset 36778 e04318f39f92
parent 36526 3b41f1c69604
child 36991 7f814aac1f80
equal deleted inserted replaced
36777:28d33fb9097f 36778:e04318f39f92
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    27  * @summary Verifies that javah won't attempt to generate a header file if a
    27  * @summary Verifies that javah won't attempt to generate a header file if a
    28  * native method in a supplied class contains a parameter type whose corresponding
    28  * native method in a supplied class contains a parameter type whose corresponding
    29  * class is missing or not in the classpath
    29  * class is missing or not in the classpath
    30  * @library /tools/lib
    30  * @library /tools/lib
    31  * @modules jdk.compiler/com.sun.tools.javac.api
    31  * @modules jdk.compiler/com.sun.tools.javac.api
    32  *          jdk.compiler/com.sun.tools.javac.file
       
    33  *          jdk.compiler/com.sun.tools.javac.main
    32  *          jdk.compiler/com.sun.tools.javac.main
    34  *          jdk.jdeps/com.sun.tools.javap
    33  * @build toolbox.ToolBox toolbox.JavahTask
    35  * @build ToolBox
       
    36  * @run compile MissingParamClassTest.java
    34  * @run compile MissingParamClassTest.java
    37  * @clean MissingParamClassException
    35  * @clean MissingParamClassException
    38  * @run main MissingParamClassTest
    36  * @run main MissingParamClassTest
    39  * @run compile MissingParamClassTest.java
    37  * @run compile MissingParamClassTest.java
    40  * @clean Param
    38  * @clean Param
    42  */
    40  */
    43 
    41 
    44 import java.nio.file.Files;
    42 import java.nio.file.Files;
    45 import java.nio.file.Paths;
    43 import java.nio.file.Paths;
    46 
    44 
       
    45 import toolbox.JavahTask;
       
    46 import toolbox.Task;
       
    47 import toolbox.ToolBox;
       
    48 
    47 // Original test: test/tools/javah/MissingParamClassTest.sh
    49 // Original test: test/tools/javah/MissingParamClassTest.sh
    48 public class MissingParamClassTest {
    50 public class MissingParamClassTest {
    49 
    51 
    50     public static void main(String[] args) throws Exception {
    52     public static void main(String[] args) throws Exception {
    51         ToolBox tb = new ToolBox();
    53         ToolBox tb = new ToolBox();
    52 
    54 
    53         String out = tb.new JavahTask()
    55         String out = new JavahTask(tb)
    54                 .classpath(ToolBox.testClasses)
    56                 .classpath(ToolBox.testClasses)
    55                 .classes("ParamClassTest")
    57                 .classes("ParamClassTest")
    56                 .run(ToolBox.Expect.FAIL)
    58                 .run(Task.Expect.FAIL)
    57                 .getOutput(ToolBox.OutputKind.DIRECT);
    59                 .getOutput(Task.OutputKind.DIRECT);
    58 
    60 
    59         if (Files.exists(Paths.get("ParamClassTest.h")) || out.isEmpty())
    61         if (Files.exists(Paths.get("ParamClassTest.h")) || out.isEmpty())
    60             throw new AssertionError("The only output generated by javah must be an error message");
    62             throw new AssertionError("The only output generated by javah must be an error message");
    61     }
    63     }
    62 
    64