/* * Copyright (c) 2003, 2016, 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 * @modules jdk.javadoc/jdk.javadoc.internal.tool * @build JavadocTester * @run main TestNewLanguageFeatures */ public class TestNewLanguageFeatures extends JavadocTester { public static void main(String... args) throws Exception { TestNewLanguageFeatures tester = new TestNewLanguageFeatures(); tester.runTests(); } @Test void test() { javadoc("-Xdoclint:none", "-d", "out", "-use", "-sourcepath", testSrc, "pkg", "pkg1", "pkg2"); checkExit(Exit.OK); checkEnums(); checkTypeParameters(); checkVarArgs(); checkAnnotationTypeUsage(); } //================================= // ENUM TESTING //================================= void checkEnums() { checkOutput("pkg/Coin.html", true, // Make sure enum header is correct. "Enum Coin", // Make sure enum signature is correct. "
public enum "
+ "Coin\n"
+ "extends java.lang.Enum<Coin>
",
// Check for enum constant section
"public static Coin" + " valueOf(java.lang.String name)\n" + "
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no " +
"constant with the specified namejava.lang.NullPointerException
- if the argument is nullE
- "
+ "the type parameter for this class.",
// Type parameters in @see/@link
"TypeParameters
T
- This is the first "
+ "type parameter.V
- This is the second type "
+ "parameter.",
// Signature of method with type parameters
"public <T extends java.util.List,V> "
+ "java.lang.String[] methodThatHasTypeParameters",
// Method that returns TypeParameters
"E[]
"
+ ""
+ "methodThatReturnsTypeParameterA(E[] e)
",
"public E[] " + "methodThatReturnsTypeParameterA(E[] e)\n", "
<T extends java.lang.Object & java.lang.Comparable<? super T>>"
+ "
T
"
+ ""
+ "methodtThatReturnsTypeParametersB(java.util.Collection<? extends T> coll)
\n"
+ "<X extends java.lang.Throwable>
"
+ "E"
+ "
"
+ ""
+ "orElseThrow(java.util.function.Supplier<? extends X> exceptionSupplier)
"
);
checkOutput("pkg/Wildcards.html", true,
// Wildcard testing.
""
+ "TypeParameters<? super java.lang.String> a",
""
+ "TypeParameters<? extends java.lang.StringBuffer> b",
""
+ "TypeParameters c");
checkOutput(Output.OUT, true,
// Bad type parameter warnings.
"warning - @param argument "
+ "\"public class TypeParameterSubClass<T extends "
+ "java.lang.String>\n"
+ "extends "
+ ""
+ "TypeParameterSuperClass<T>
");
// Interface generic parameter substitution
// Signature of subclass that has type parameters.
checkOutput("pkg/TypeParameters.html", true,
""
+ "SubInterface<E>
, SuperInterface<E>
"
+ "SubInterface<V>
"
+ "SuperInterface<V>
ClassUseTest1<T extends "
+ "Foo"
+ " & "
+ "Foo2>
method"
+ "(T t)
ParamTest"
+ "<Foo>
ParamTest<Foo>
ClassUseTest1<T extends "
+ "Foo"
+ " & "
+ "Foo2>
method"
+ "(T t)
ClassUseTest2<T extends "
+ ""
+ "ParamTest<"
+ "Foo3>>
method"
+ "(T t)
ParamTest"
+ "<"
+ "Foo>
<T extends ParamTest"
+ "<Foo3>>
ParamTest"
+ "<Foo3>
ClassUseTest2<T extends "
+ ""
+ "ParamTest<"
+ "Foo3>>
method"
+ "(T t)
<T extends ParamTest<"
+ "Foo3"
+ ">>
ParamTest<Foo3>
ClassUseTest3<T extends "
+ ""
+ "ParamTest2<java.util.List<? extends "
+ ""
+ "Foo4>>>
method(T t)
<T extends "
+ "ParamTest2<java.util.List<? extends Foo4>"
+ ">>
ParamTest2<java.util.List"
+ "<? extends Foo4>>
ClassUseTest3<T extends "
+ ""
+ "ParamTest2<java.util.List<? extends "
+ ""
+ "Foo4>>>
method(T t)
"
+ " <T extends "
+ "ParamTest2<java.util.List<? extends Foo4>"
+ ">>
ParamTest2<java.util.List"
+ "<? extends Foo4>>
void
method(java."
+ "util.Set<Foo4> p)
@AnnotationType("
+ "optional"
+ "=\"Class Annotation\",\n"
+ " "
+ "required=1994)\n"
+ "public class "
+ "AnnotationTypeUsage\n"
+ "extends java.lang.Object
",
// FIELD
"@AnnotationType(" + "optional" + "=\"Field Annotation\",\n" + " " + "required=1994)\n" + "public int field", // CONSTRUCTOR "
@AnnotationType(" + "optional" + "=\"Constructor Annotation\",\n" + " " + "required=1994)\n" + "public AnnotationTypeUsage()", // METHOD "
@AnnotationType(" + "optional" + "=\"Method Annotation\",\n" + " " + "required=1994)\n" + "public void method()", // METHOD PARAMS "
public void methodWithParams(" + "" + "@AnnotationType(" + "optional=\"Parameter Annotation\",required=1994)\n" + " int documented,\n" + " int undocmented)", // CONSTRUCTOR PARAMS "
public AnnotationTypeUsage(" + "@AnnotationType(" + "optional=\"Constructor Param Annotation\",required=1994)\n" + " int documented,\n" + " int undocmented)"); //================================= // Annotatation Type Usage //================================= checkOutput("pkg/class-use/AnnotationType.html", true, "
andcheckOutput("pkg1/B.html", true, "
@A",
"public interface B
");
}
}