/* * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 4789689 4905985 4927164 4827184 4993906 5004549 7025314 7010344 8025633 8026567 * @summary Run Javadoc on a set of source files that demonstrate new * language features. Check the output to ensure that the new * language features are properly documented. * @author jamieh * @library ../lib/ * @build JavadocTester TestNewLanguageFeatures * @run main TestNewLanguageFeatures */ public class TestNewLanguageFeatures extends JavadocTester { //Test information. private static final String BUG_ID = "4789689-4905985-4927164-4827184-4993906"; //Javadoc arguments. private static final String[] ARGS = new String[] { "-Xdoclint:none", "-d", BUG_ID, "-use", "-source", "1.5", "-sourcepath", SRC_DIR, "pkg", "pkg1", "pkg2" }; //Input for string search tests. private static final String[][] TEST = { //================================= // ENUM TESTING //================================= //Make sure enum header is correct. {BUG_ID + FS + "pkg" + FS + "Coin.html", "Enum Coin"}, //Make sure enum signature is correct. {BUG_ID + FS + "pkg" + FS + "Coin.html", "
public enum " +
                     "Coin" + NL +
                     "extends java.lang.Enum<Coin>
" }, //Check for enum constant section {BUG_ID + FS + "pkg" + FS + "Coin.html", "Enum Constants" + " "}, //Detail for enum constant {BUG_ID + FS + "pkg" + FS + "Coin.html", "Dime"}, //Automatically insert documentation for values() and valueOf(). {BUG_ID + FS + "pkg" + FS + "Coin.html", "Returns an array containing the constants of this enum type,"}, {BUG_ID + FS + "pkg" + FS + "Coin.html", "Returns the enum constant of this type with the specified name"}, {BUG_ID + FS + "pkg" + FS + "Coin.html", "for (Coin c : Coin.values())"}, {BUG_ID + FS + "pkg" + FS + "Coin.html", "Overloaded valueOf() method has correct documentation."}, {BUG_ID + FS + "pkg" + FS + "Coin.html", "Overloaded values method has correct documentation."}, //================================= // TYPE PARAMETER TESTING //================================= //Make sure the header is correct. {BUG_ID + FS + "pkg" + FS + "TypeParameters.html", "Class TypeParameters<E>"}, //Check class type parameters section. {BUG_ID + FS + "pkg" + FS + "TypeParameters.html", "
Type Parameters:
" + NL + "
E - " + "the type parameter for this class."}, //Type parameters in @see/@link {BUG_ID + FS + "pkg" + FS + "TypeParameters.html", "
" + NL + "
See Also:
" + NL + "
" + "" + "TypeParameters
" + NL + "
"}, //Method that uses class type parameter. {BUG_ID + FS + "pkg" + FS + "TypeParameters.html", "(E param)"}, //Method type parameter section. {BUG_ID + FS + "pkg" + FS + "TypeParameters.html", "Type Parameters:" + NL + "
T - This is the first " + "type parameter.
" + NL + "
V - This is the second type " + "parameter."}, //Signature of method with type parameters {BUG_ID + FS + "pkg" + FS + "TypeParameters.html", "public <T extends java.util.List,V> " + "java.lang.String[] methodThatHasTypeParameters"}, //Wildcard testing. {BUG_ID + FS + "pkg" + FS + "Wildcards.html", "" + "TypeParameters<? super java.lang.String> a"}, {BUG_ID + FS + "pkg" + FS + "Wildcards.html", "" + "TypeParameters<? extends java.lang.StringBuffer> b"}, {BUG_ID + FS + "pkg" + FS + "Wildcards.html", "" + "TypeParameters c"}, //Bad type parameter warnings. {WARNING_OUTPUT, "warning - @param argument " + "\"\" is not a type parameter name."}, {WARNING_OUTPUT, "warning - @param argument " + "\"\" is not a type parameter name."}, //Signature of subclass that has type parameters. {BUG_ID + FS + "pkg" + FS + "TypeParameterSubClass.html", "
public class TypeParameterSubClass<T extends " +
                "java.lang.String>" + NL + "extends " +
                "" +
                "TypeParameterSuperClass<T>
"}, //Interface generic parameter substitution //Signature of subclass that has type parameters. {BUG_ID + FS + "pkg" + FS + "TypeParameters.html", "
" + NL + "
All Implemented Interfaces:
" + NL + "
" + "SubInterface<E>, SuperInterface<E>
" + NL + "
"}, {BUG_ID + FS + "pkg" + FS + "SuperInterface.html", "
" + NL + "
All Known Subinterfaces:
" + NL + "
" + "SubInterface<V>
" + NL + "
"}, {BUG_ID + FS + "pkg" + FS + "SubInterface.html", "
" + NL + "
All Superinterfaces:
" + NL + "
" + "SuperInterface<V>
" + NL + "
"}, //================================= // VAR ARG TESTING //================================= {BUG_ID + FS + "pkg" + FS + "VarArgs.html", "(int... i)"}, {BUG_ID + FS + "pkg" + FS + "VarArgs.html", "(int[][]... i)"}, {BUG_ID + FS + "pkg" + FS + "VarArgs.html", "-int:A...-"}, {BUG_ID + FS + "pkg" + FS + "VarArgs.html", "" + "TypeParameters... t"}, //================================= // ANNOTATION TYPE TESTING //================================= //Make sure the summary links are correct. {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", "
  • Summary: 
  • " + NL + "
  • Field | 
  • " + NL + "
  • " + "Required | 
  • " + NL + "
  • " + "Optional
  • "}, //Make sure the detail links are correct. {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", "
  • Detail: 
  • " + NL + "
  • Field | 
  • " + NL + "
  • Element
  • "}, //Make sure the heading is correct. {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", "Annotation Type AnnotationType"}, //Make sure the signature is correct. {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", "public @interface AnnotationType"}, //Make sure member summary headings are correct. {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", "

    Required Element Summary

    "}, {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", "

    Optional Element Summary

    "}, //Make sure element detail heading is correct {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", "Element Detail"}, //Make sure default annotation type value is printed when necessary. {BUG_ID + FS + "pkg" + FS + "AnnotationType.html", "
    " + NL + "
    Default:
    " + NL + "
    \"unknown\"
    " + NL + "
    "}, //================================= // ANNOTATION TYPE USAGE TESTING //================================= //PACKAGE {BUG_ID + FS + "pkg" + FS + "package-summary.html", "@AnnotationType(optional=\"Package Annotation\"," + NL + " required=1994)"}, //CLASS {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "
    @AnnotationType(" +
                    "optional" +
                    "=\"Class Annotation\"," + NL +
                    "                " +
                    "required=1994)" + NL + "public class " +
                    "AnnotationTypeUsage" + NL + "extends java.lang.Object
    "}, //FIELD {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "
    @AnnotationType(" +
                    "optional" +
                    "=\"Field Annotation\"," + NL +
                    "                " +
                    "required=1994)" + NL + "public int field
    "}, //CONSTRUCTOR {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "
    @AnnotationType(" +
                    "optional" +
                    "=\"Constructor Annotation\"," + NL +
                    "                " +
                    "required=1994)" + NL + "public AnnotationTypeUsage()
    "}, //METHOD {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "
    @AnnotationType(" +
                    "optional" +
                    "=\"Method Annotation\"," + NL +
                    "                " +
                    "required=1994)" + NL + "public void method()
    "}, //METHOD PARAMS {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "
    public void methodWithParams(" +
                    "" +
                    "@AnnotationType(" +
                    "optional=\"Parameter Annotation\",required=1994)" + NL +
                    "                             int documented," + NL +
                    "                             int undocmented)
    "}, //CONSTRUCTOR PARAMS {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "
    public AnnotationTypeUsage(" +
                    "@AnnotationType(" +
                    "optional=\"Constructor Param Annotation\",required=1994)" + NL +
                    "                           int documented," + NL +
                    "                           int undocmented)
    "}, //================================= // ANNOTATION TYPE USAGE TESTING (All Different Types). //================================= //Integer {BUG_ID + FS + "pkg1" + FS + "B.html", "d=3.14,"}, //Double {BUG_ID + FS + "pkg1" + FS + "B.html", "d=3.14,"}, //Boolean {BUG_ID + FS + "pkg1" + FS + "B.html", "b=true,"}, //String {BUG_ID + FS + "pkg1" + FS + "B.html", "s=\"sigh\","}, //Class {BUG_ID + FS + "pkg1" + FS + "B.html", "c=Foo.class,"}, //Bounded Class {BUG_ID + FS + "pkg1" + FS + "B.html", "w=TypeParameterSubClass.class,"}, //Enum {BUG_ID + FS + "pkg1" + FS + "B.html", "e=Penny,"}, //Annotation Type {BUG_ID + FS + "pkg1" + FS + "B.html", "a=@AnnotationType(optional=\"foo\",required=1994),"}, //String Array {BUG_ID + FS + "pkg1" + FS + "B.html", "sa={\"up\",\"down\"},"}, //Primitive {BUG_ID + FS + "pkg1" + FS + "B.html", "primitiveClassTest=boolean.class,"}, //XXX: Add array test case after this if fixed: //5020899: Incorrect internal representation of class-valued annotation elements //Make sure that annotations are surrounded by
     and 
    {BUG_ID + FS + "pkg1" + FS + "B.html", "
    @A"},
                {BUG_ID + FS + "pkg1" + FS + "B.html",
                    "public interface B
    "}, //============================================================== // Handle multiple bounds. //============================================================== {BUG_ID + FS + "pkg" + FS + "MultiTypeParameters.html", "public <T extends java.lang.Number & java.lang.Runnable> T foo(T t)"}, //============================================================== // Test Class-Use Documenation for Type Parameters. //============================================================== //ClassUseTest1: {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html", "Classes in pkg2 with type parameters of " + "type " + "Foo " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html", "ClassUseTest1<T extends " + "Foo" + " & " + "Foo2> " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html", "Methods in pkg2 with type parameters of " + "type Foo " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html", "ClassUseTest1." + "method" + "(T t) " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html", "Fields in pkg2 with type parameters of " + "type " + "Foo " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html", "td class=\"colFirst\">ParamTest" + "<Foo>" }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", "Fields in pkg2 declared as ParamTest" + " " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", "ParamTest<Foo>" }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html", "Classes in pkg2 with type parameters of " + "type Foo2 " + "" }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html", "ClassUseTest1<T extends " + "Foo" + " & " + "Foo2> " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html", "Methods in pkg2 with type parameters of " + "type Foo2 " + "" }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html", "" + "ClassUseTest1.method" + "(T t) " }, //ClassUseTest2: > {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", "Classes in pkg2 with type parameters of " + "type ParamTest" + " " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", "ClassUseTest2<T extends " + "" + "ParamTest<" + "Foo3>> " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", "Methods in pkg2 with type parameters of " + "type ParamTest" + " " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", "ClassUseTest2." + "method" + "(T t) " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", "Fields in pkg2 declared as ParamTest" + " " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", "ParamTest" + "<" + "Foo>" }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", "Methods in pkg2 with type parameters of " + "type ParamTest" + " " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html", "<T extends ParamTest" + "<Foo3>>
    ParamTest" + "<Foo3>
    " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html", "Classes in pkg2 with type parameters of " + "type " + "Foo3 " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html", "ClassUseTest2<T extends " + "" + "ParamTest<" + "Foo3>> " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html", "Methods in pkg2 with type parameters of " + "type Foo3 " + "" }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html", "ClassUseTest2." + "method" + "(T t) " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html", "Methods in pkg2 that return types with " + "arguments of type Foo3" + " " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html", "<T extends ParamTest<" + "Foo3" + ">>
    ParamTest<Foo3>
    " }, //ClassUseTest3: >> {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html", "Classes in pkg2 with type parameters of " + "type ParamTest2" + " " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html", "ClassUseTest3<T extends " + "" + "ParamTest2<java.util.List<? extends " + "" + "Foo4>>> " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html", "Methods in pkg2 with type parameters of " + "type ParamTest2" + " " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html", "ClassUseTest3" + ".method(T t) " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html", "<T extends " + "ParamTest2<java.util.List<? extends Foo4>" + ">>
    ParamTest2<java.util.List" + "<? extends Foo4>>
    " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", "Classes in pkg2 with type parameters of " + "type Foo4 " + "" }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", "ClassUseTest3<T extends " + "" + "ParamTest2<java.util.List<? extends " + "" + "Foo4>>> " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", "Methods in pkg2 with type parameters of " + "type Foo4 " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", "ClassUseTest3." + "method(T t)" + " " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", "Methods in pkg2 that return types with " + "arguments of type Foo4 " }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", "<T extends " + "ParamTest2<java.util.List<? extends Foo4>" + ">>
    ParamTest2<java.util.List" + "<? extends Foo4>>
    " }, //Type parameters in constructor and method args {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", "Method parameters in pkg2 with type arguments of " + "type Foo4 " + "" + NL + "" + NL + "Modifier and Type" + NL + "Method and Description" + NL + "" + NL + "" + NL + "" + NL + "void" + NL + "ClassUseTest3." + "method(java." + "util.Set<Foo4> p) " + NL + "" + NL + "" }, {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html", "Constructor parameters in pkg2 with type arguments " + "of type Foo4 " + "" }, //================================= // Annotatation Type Usage //================================= {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html", "Packages with annotations of type " + "AnnotationType " + "" }, {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html", "Classes in pkg with annotations of type " + "AnnotationType " }, {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html", "Fields in pkg with annotations of type " + "AnnotationType" + " " }, {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html", "Methods in pkg with annotations of type " + "AnnotationType" + " " }, {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html", "Method parameters in pkg with annotations of type " + "AnnotationType" + " " }, {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html", "Constructors in pkg with annotations of type " + "AnnotationType" + " " }, {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html", "Constructor parameters in pkg with annotations of " + "type AnnotationType " }, //================================= // TYPE PARAMETER IN INDEX //================================= {BUG_ID + FS + "index-all.html", "" + "method(Vector<Object>)" }, //================================= // TYPE PARAMETER IN INDEX //================================= {BUG_ID + FS + "index-all.html", "" + "method(Vector<Object>)" }, }; private static final String[][] NEGATED_TEST = { //================================= // ENUM TESTING //================================= //NO constructor section {BUG_ID + FS + "pkg" + FS + "Coin.html", "

    Constructor Summary

    "}, //================================= // TYPE PARAMETER TESTING //================================= //No type parameters in class frame. {BUG_ID + FS + "allclasses-frame.html", "" + "TypeParameters<E>" }, //============================================================== // ANNOTATION TYPE USAGE TESTING (When @Documented is omitted) //=============================================================== //CLASS {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "@AnnotationTypeUndocumented(optional=\"Class Annotation\"," + NL + " required=1994)" + NL + "public class AnnotationTypeUsage
    extends java.lang.Object
    "}, //FIELD {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "@AnnotationTypeUndocumented(optional=\"Field Annotation\"," + NL + " required=1994)" + NL + "public int field"}, //CONSTRUCTOR {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "@AnnotationTypeUndocumented(optional=\"Constructor Annotation\"," + NL + " required=1994)" + NL + "public AnnotationTypeUsage()"}, //METHOD {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html", "@AnnotationTypeUndocumented(optional=\"Method Annotation\"," + NL + " required=1994)" + NL + "public void method()"}, //================================= // Make sure annotation types do not // trigger this warning. //================================= {WARNING_OUTPUT, "Internal error: package sets don't match: [] with: null" }, }; /** * The entry point of the test. * @param args the array of command line arguments. */ public static void main(String[] args) { TestNewLanguageFeatures tester = new TestNewLanguageFeatures(); run(tester, ARGS, TEST, NEGATED_TEST); tester.printSummary(); } /** * {@inheritDoc} */ public String getBugId() { return BUG_ID; } /** * {@inheritDoc} */ public String getBugName() { return getClass().getName(); } }