langtools/test/tools/javadoc/sourceOption/SourceOption.java
changeset 23139 612191246a7d
parent 5520 86e4b9a9da40
child 30730 d3ce7619db2c
equal deleted inserted replaced
23138:497fb20a5754 23139:612191246a7d
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug     6507179
    26  * @bug     6507179
    27  * @summary Ensure that "-source" option isn't ignored.
    27  * @summary Ensure that "-source" option isn't ignored.
    28  * @author  Scott Seligman
    28  * @author  Scott Seligman
       
    29  * @run main/fail SourceOption 7
       
    30  * @run main      SourceOption 9
       
    31  * @run main      SourceOption
       
    32  */
       
    33 
       
    34 /*
       
    35  * TEST NOTE
       
    36  * With JDK9, this test has been transformed into a NEGATIVE test.
       
    37  *
       
    38  * Generally speaking, this test should check a feature not in at least
       
    39  * one of the currently supported previous versions.  In this manner,
       
    40  * a failure of the -source option to be honored would mean a pass of
       
    41  * the test, and therefore a failure of the -source option.
       
    42  *
       
    43  * For JDK9 and JDK10, both support 1.7, which did not support javac's
       
    44  * lambda construct.  So we set "-source 1.7" to compile a .java file
       
    45  * containing the lambda construct.  javac should fail, thus showing
       
    46  * -source to be working.  Thus the test passes.
       
    47  *
       
    48  * The second jtreg @run command checks to make sure that the source
       
    49  * provided is valid for the current release of the JDK.
       
    50  *
       
    51  *  fixVersion: JDK11
       
    52  *      replace ./p/LambdaConstructTest.java with a missing from
       
    53  *      JDK8, JDK9, or JDK10.  Set -source below appropriately.
    29  */
    54  */
    30 
    55 
    31 import com.sun.javadoc.*;
    56 import com.sun.javadoc.*;
    32 
    57 
    33 public class SourceOption extends Doclet {
    58 public class SourceOption extends Doclet {
    34 
    59 
    35     public static void main(String[] args) {
    60     public static void main(String[] args) {
       
    61         String[] params;
       
    62         if ((args == null) || (args.length==0)) {
       
    63             params = new String[]{"p"};
       
    64             System.out.println("NOTE : -source not provided, default taken");
       
    65         } else {
       
    66             params = new String[]{"-source", args[0], "p"};
       
    67             System.out.println("NOTE : -source will be: " + args[0]);
       
    68         }
       
    69 
    36         if (com.sun.tools.javadoc.Main.execute(
    70         if (com.sun.tools.javadoc.Main.execute(
    37                 "javadoc",
    71                 "javadoc",
    38                 "SourceOption",
    72                 "SourceOption",
    39                 SourceOption.class.getClassLoader(),
    73                 SourceOption.class.getClassLoader(),
    40                 new String[] {"-source", "1.3", "p"}) != 0)
    74                 params) != 0)
    41             throw new Error("Javadoc encountered warnings or errors.");
    75         throw new Error("Javadoc encountered warnings or errors.");
       
    76 
    42     }
    77     }
    43 
    78 
    44     public static boolean start(RootDoc root) {
    79     public static boolean start(RootDoc root) {
    45         root.classes();         // force parser into action
    80         root.classes();         // force parser into action
    46         return true;
    81         return true;