/* * Copyright (c) 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 8005091 8009686 8025633 * @summary Make sure that type annotations are displayed correctly * @author Bhavesh Patel * @library ../lib/ * @build JavadocTester TestTypeAnnotations * @run main TestTypeAnnotations */ public class TestTypeAnnotations extends JavadocTester { //Test information. private static final String BUG_ID = "8005091-8009686"; //Javadoc arguments. private static final String[] ARGS = new String[] { "-d", BUG_ID, "-sourcepath", SRC_DIR, "-private", "typeannos" }; //Input for string search tests. private static final String[][] NEGATED_TEST = NO_TEST; private static final String[][] TEST = { // Test for type annotations on Class Extends (ClassExtends.java). {BUG_ID + FS + "typeannos" + FS + "MyClass.html", "extends @ClassExtA ParameterizedClass<" + "@ClassExtB java.lang.String>" }, {BUG_ID + FS + "typeannos" + FS + "MyClass.html", "implements @ClassExtB java.lang.CharSequence, " + "@ClassExtA ParameterizedInterface<" + "@ClassExtB java.lang.String>" }, {BUG_ID + FS + "typeannos" + FS + "MyInterface.html", "extends @ClassExtA " + "ParameterizedInterface<@ClassExtA java.lang.String>, " + "@ClassExtB java.lang.CharSequence" }, // Test for type annotations on Class Parameters (ClassParameters.java). {BUG_ID + FS + "typeannos" + FS + "ExtendsBound.html", "class ExtendsBound<K extends @ClassParamA java.lang.String>" }, {BUG_ID + FS + "typeannos" + FS + "ExtendsGeneric.html", "
class ExtendsGeneric<K extends " + "@ClassParamA Unannotated<" + "@ClassParamB java.lang.String>>" }, {BUG_ID + FS + "typeannos" + FS + "TwoBounds.html", "class TwoBounds<K extends " + "@ClassParamA java.lang.String,V extends @ClassParamB" + " java.lang.String>" }, {BUG_ID + FS + "typeannos" + FS + "Complex1.html", "class Complex1<K extends " + "@ClassParamA java.lang.String & java.lang.Runnable>" }, {BUG_ID + FS + "typeannos" + FS + "Complex2.html", "class Complex2<K extends java.lang." + "String & @ClassParamB java.lang.Runnable>" }, {BUG_ID + FS + "typeannos" + FS + "ComplexBoth.html", "class ComplexBoth<K extends @ClassParamA java.lang.String & @ClassParamA" + " java.lang.Runnable>" }, // Test for type annotations on fields (Fields.java). {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html", "Parameterized<@FldA java.lang.String," + "@FldB java.lang.String> bothTypeArgs" }, {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html", "@FldA java.lang.String @FldB [] " + "array1Deep" }, {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html", "java.lang.String[] @FldB [] array2SecondOld" }, {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html", "@FldD java.lang.String @FldC @FldA" + " [] @FldC @FldB [] array2Deep" }, {BUG_ID + FS + "typeannos" + FS + "ModifiedScoped.html", "public final Parameterized<@FldA " + "Parameterized<@FldA java.lang.String," + "@FldB java.lang.String>,@FldB java.lang.String> " + "nestedParameterized" }, {BUG_ID + FS + "typeannos" + FS + "ModifiedScoped.html", "public final @FldA java.lang.String[][] " + "array2" }, // Test for type annotations on method return types (MethodReturnType.java). {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html", "public <T> @MRtnA java.lang.String" + " method()" }, {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html", "@MRtnA java.lang.String @MRtnA [] " + "@MRtnB [] array2Deep()" }, {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html", "@MRtnA java.lang.String[][] array2()" }, {BUG_ID + FS + "typeannos" + FS + "MtdModifiedScoped.html", "public final MtdParameterized<@MRtnA " + "MtdParameterized<@MRtnA java.lang." + "String,@MRtnB java.lang.String>,@MRtnB java." + "lang.String> nestedMtdParameterized()" }, // Test for type annotations on method type parameters (MethodTypeParameters.java). {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html", "<K extends @MTyParamA java.lang.String>" + " void methodExtends()" }, {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html", "<K extends @MTyParamA " + "MtdTyParameterized<@MTyParamB java.lang.String" + ">> void nestedExtends()" }, {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html", "public final <K extends @MTyParamA " + "java.lang.String> void methodExtends()" }, {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html", "public final <K extends @MTyParamA " + "java.lang.String,V extends @MTyParamA " + "MtdTyParameterized<@MTyParamB java.lang.String" + ">> void dual()" }, // Test for type annotations on parameters (Parameters.java). {BUG_ID + FS + "typeannos" + FS + "Parameters.html", "void unannotated(" + "ParaParameterized<java.lang.String,java.lang.String>" + " a)" }, {BUG_ID + FS + "typeannos" + FS + "Parameters.html", "void nestedParaParameterized(" + "ParaParameterized<@ParamA " + "ParaParameterized<@ParamA java.lang.String," + "@ParamB java.lang.String>,@ParamB" + " java.lang.String> a)" }, {BUG_ID + FS + "typeannos" + FS + "Parameters.html", "void array2Deep(@ParamA java.lang.String " + "@ParamA [] @ParamB [] a)" }, // Test for type annotations on throws (Throws.java). {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html", "void oneException()" + NL + " throws @ThrA java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html", "void twoExceptions()" + NL + " throws @ThrA java.lang.RuntimeException," + NL + " @ThrA java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html", "public final void oneException(java.lang.String a)" + NL + " throws @ThrA java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html", "public final void twoExceptions(java.lang.String a)" + NL + " throws @ThrA java.lang.RuntimeException," + NL + " @ThrA java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html", "void oneException()" + NL + " throws @ThrB(value=\"m\") java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html", "void twoExceptions()" + NL + " throws @ThrB(value=\"m\") java.lang.RuntimeException," + NL + " @ThrA java.lang.Exception" }, // Test for type annotations on type parameters (TypeParameters.java). {BUG_ID + FS + "typeannos" + FS + "TestMethods.html", "<K,V extends @TyParaA java.lang.String> " + "void secondAnnotated()" }, // Test for type annotations on wildcard type (Wildcards.java). {BUG_ID + FS + "typeannos" + FS + "BoundTest.html", "void wcExtends(MyList<? extends @WldA" + " java.lang.String> l)" }, {BUG_ID + FS + "typeannos" + FS + "BoundTest.html", "MyList<? super @WldA java.lang.String>" + " returnWcSuper()" }, {BUG_ID + FS + "typeannos" + FS + "BoundWithValue.html", "void wcSuper(MyList<? super @WldB(value=\"m\") java.lang." + "String> l)" }, {BUG_ID + FS + "typeannos" + FS + "BoundWithValue.html", "MyList<? extends @WldB(value=\"m\") java.lang.String" + "> returnWcExtends()" }, // Test for receiver annotations (Receivers.java). {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html", "void withException(@RcvrA " + "DefaultUnmodified this)" + NL + " throws java." + "lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html", "java.lang.String nonVoid(@RcvrA @RcvrB" + "(value=\"m\")" + " DefaultUnmodified this)" }, {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html", "<T extends java.lang.Runnable> void accept(" + "@RcvrA DefaultUnmodified this," + NL + " T r)" + NL + " throws java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "PublicModified.html", "public final java.lang.String nonVoid(" + "@RcvrA PublicModified this)" }, {BUG_ID + FS + "typeannos" + FS + "PublicModified.html", "public final <T extends java.lang.Runnable> " + "void accept(@RcvrA PublicModified this," + NL + " T r)" + NL + " throws java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "WithValue.html", "<T extends java.lang.Runnable> void accept(" + "@RcvrB(" + "value=\"m\") WithValue this," + NL + " T r)" + NL + " throws java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "WithFinal.html", "java.lang.String nonVoid(@RcvrB(value=\"m\") WithFinal" + " this)" }, {BUG_ID + FS + "typeannos" + FS + "WithBody.html", "void field(@RcvrA WithBody this)" }, {BUG_ID + FS + "typeannos" + FS + "Generic2.html", "void test2(@RcvrA Generic2<X> this)" } }; /** * The entry point of the test. * @param args the array of command line arguments. */ public static void main(String[] args) { TestTypeAnnotations tester = new TestTypeAnnotations(); run(tester, ARGS, TEST, NEGATED_TEST); tester.printSummary(); } /** * {@inheritDoc} */ public String getBugId() { return BUG_ID; } /** * {@inheritDoc} */ public String getBugName() { return getClass().getName(); } }