langtools/test/tools/javadoc/sourceOption/SourceOption.java
author akulyakh
Thu, 21 May 2015 11:41:04 -0700
changeset 30730 d3ce7619db2c
parent 23139 612191246a7d
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:
813
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 23139
diff changeset
     2
 * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
813
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
     4
 *
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
     8
 *
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    13
 * accompanied this code).
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    14
 *
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    18
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
    21
 * questions.
813
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    22
 */
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    23
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    24
/*
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    25
 * @test
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    26
 * @bug     6507179
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    27
 * @summary Ensure that "-source" option isn't ignored.
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    28
 * @author  Scott Seligman
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 23139
diff changeset
    29
 * @modules jdk.javadoc
23139
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    30
 * @run main/fail SourceOption 7
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    31
 * @run main      SourceOption 9
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    32
 * @run main      SourceOption
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    33
 */
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    34
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    35
/*
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    36
 * TEST NOTE
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    37
 * With JDK9, this test has been transformed into a NEGATIVE test.
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    38
 *
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    39
 * Generally speaking, this test should check a feature not in at least
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    40
 * one of the currently supported previous versions.  In this manner,
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    41
 * a failure of the -source option to be honored would mean a pass of
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    42
 * the test, and therefore a failure of the -source option.
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    43
 *
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    44
 * For JDK9 and JDK10, both support 1.7, which did not support javac's
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    45
 * lambda construct.  So we set "-source 1.7" to compile a .java file
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    46
 * containing the lambda construct.  javac should fail, thus showing
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    47
 * -source to be working.  Thus the test passes.
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    48
 *
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    49
 * The second jtreg @run command checks to make sure that the source
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    50
 * provided is valid for the current release of the JDK.
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    51
 *
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    52
 *  fixVersion: JDK11
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    53
 *      replace ./p/LambdaConstructTest.java with a missing from
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    54
 *      JDK8, JDK9, or JDK10.  Set -source below appropriately.
813
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    55
 */
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    56
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    57
import com.sun.javadoc.*;
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    58
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    59
public class SourceOption extends Doclet {
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    60
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    61
    public static void main(String[] args) {
23139
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    62
        String[] params;
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    63
        if ((args == null) || (args.length==0)) {
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    64
            params = new String[]{"p"};
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    65
            System.out.println("NOTE : -source not provided, default taken");
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    66
        } else {
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    67
            params = new String[]{"-source", args[0], "p"};
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    68
            System.out.println("NOTE : -source will be: " + args[0]);
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    69
        }
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    70
813
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    71
        if (com.sun.tools.javadoc.Main.execute(
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    72
                "javadoc",
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    73
                "SourceOption",
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 813
diff changeset
    74
                SourceOption.class.getClassLoader(),
23139
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    75
                params) != 0)
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    76
        throw new Error("Javadoc encountered warnings or errors.");
612191246a7d 8031670: Remove unneeded -source options in javadoc tests
darcy
parents: 5520
diff changeset
    77
813
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    78
    }
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    79
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    80
    public static boolean start(RootDoc root) {
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    81
        root.classes();         // force parser into action
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    82
        return true;
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    83
    }
ab91293d33f4 6507179: javadoc -source 1.3 does not work with jdk6
jjg
parents:
diff changeset
    84
}