test/langtools/tools/javadoc/sourceOption/SourceOption.java
branchniosocketimpl-branch
changeset 57208 7a45c67e73d0
parent 57207 30695f27d7ea
parent 53902 7a6fd71449e7
child 57210 a67ea4f53e56
equal deleted inserted replaced
57207:30695f27d7ea 57208:7a45c67e73d0
     1 /*
       
     2  * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     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
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 /*
       
    25  * @test
       
    26  * @bug     6507179
       
    27  * @summary Ensure that "-source" option isn't ignored.
       
    28  * @author  Scott Seligman
       
    29  * @modules jdk.javadoc
       
    30  * @run main/fail SourceOption 7
       
    31  * @run main      SourceOption 9
       
    32  * @run main      SourceOption
       
    33  */
       
    34 
       
    35 /*
       
    36  * In order to test whether or not the -source option is working
       
    37  * correctly, this test tries to parse source code that contains
       
    38  * a feature that is not available in at least one of the currently
       
    39  * supported previous versions.
       
    40  *
       
    41  * Parsing such code should be expected to fail; if the action
       
    42  * passes, that means the -source option is (incorrectly) ineffective.
       
    43  *
       
    44  * Additional actions are performed to ensure that the source
       
    45  * provided is valid for the current release of the JDK.
       
    46  *
       
    47  * As support for older versions of the platform are dropped, the
       
    48  * source code (currently p/LambdaConstructTest.java) will need to
       
    49  * be updated with a more recent feature.
       
    50  */
       
    51 
       
    52 import com.sun.javadoc.*;
       
    53 
       
    54 public class SourceOption extends Doclet {
       
    55 
       
    56     public static void main(String[] args) {
       
    57         String[] params;
       
    58         if ((args == null) || (args.length==0)) {
       
    59             params = new String[]{"p"};
       
    60             System.out.println("NOTE : -source not provided, default taken");
       
    61         } else {
       
    62             params = new String[]{"-source", args[0], "p"};
       
    63             System.out.println("NOTE : -source will be: " + args[0]);
       
    64         }
       
    65 
       
    66         if (com.sun.tools.javadoc.Main.execute(
       
    67                 "javadoc",
       
    68                 "SourceOption",
       
    69                 SourceOption.class.getClassLoader(),
       
    70                 params) != 0)
       
    71         throw new Error("Javadoc encountered warnings or errors.");
       
    72 
       
    73     }
       
    74 
       
    75     public static boolean start(RootDoc root) {
       
    76         root.classes();         // force parser into action
       
    77         return true;
       
    78     }
       
    79 }