bpatel@1686: /* bpatel@1686: * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. bpatel@1686: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. bpatel@1686: * bpatel@1686: * This code is free software; you can redistribute it and/or modify it bpatel@1686: * under the terms of the GNU General Public License version 2 only, as bpatel@1686: * published by the Free Software Foundation. bpatel@1686: * bpatel@1686: * This code is distributed in the hope that it will be useful, but WITHOUT bpatel@1686: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or bpatel@1686: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License bpatel@1686: * version 2 for more details (a copy is included in the LICENSE file that bpatel@1686: * accompanied this code). bpatel@1686: * bpatel@1686: * You should have received a copy of the GNU General Public License version bpatel@1686: * 2 along with this work; if not, write to the Free Software Foundation, bpatel@1686: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. bpatel@1686: * bpatel@1686: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA bpatel@1686: * or visit www.oracle.com if you need additional information or have any bpatel@1686: * questions. bpatel@1686: */ bpatel@1686: bpatel@1686: /* bpatel@1686: * @test bpatel@1691: * @bug 8005091 8009686 bpatel@1686: * @summary Make sure that type annotations are displayed correctly bpatel@1686: * @author Bhavesh Patel bpatel@1686: * @library ../lib/ bpatel@1686: * @build JavadocTester TestTypeAnnotations bpatel@1686: * @run main TestTypeAnnotations bpatel@1686: */ bpatel@1686: bpatel@1686: public class TestTypeAnnotations extends JavadocTester { bpatel@1686: bpatel@1686: //Test information. bpatel@1691: private static final String BUG_ID = "8005091-8009686"; bpatel@1686: bpatel@1686: //Javadoc arguments. bpatel@1686: private static final String[] ARGS = new String[] { bpatel@1686: "-d", BUG_ID, "-sourcepath", SRC_DIR, "-private", "typeannos" bpatel@1686: }; bpatel@1686: bpatel@1686: //Input for string search tests. bpatel@1686: private static final String[][] NEGATED_TEST = NO_TEST; bpatel@1686: private static final String[][] TEST = { bpatel@1686: // Test for type annotations on Class Extends (ClassExtends.java). bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "MyClass.html", bpatel@1691: "extends @ClassExtA ParameterizedClass<" + bpatel@1691: "@ClassExtB java.lang.String>" bpatel@1691: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "MyClass.html", bpatel@1686: "implements @ClassExtB java.lang.CharSequence, " + bpatel@1691: "@ClassExtA ParameterizedInterface<" + bpatel@1691: "@ClassExtB java.lang.String>" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "MyInterface.html", bpatel@1691: "extends @ClassExtA " + bpatel@1691: "ParameterizedInterface<@ClassExtA java.lang.String>, " + bpatel@1691: "@ClassExtB java.lang.CharSequence" bpatel@1686: }, bpatel@1686: bpatel@1686: // Test for type annotations on Class Parameters (ClassParameters.java). bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "ExtendsBound.html", bpatel@1686: "class ExtendsBound<K extends @ClassParamA java.lang.String>" bpatel@1686: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "ExtendsGeneric.html", bpatel@1858: "
class ExtendsGeneric<K extends " +
bpatel@1691:             "@ClassParamA Unannotated<" +
bpatel@1691:             "@ClassParamB java.lang.String>>"
bpatel@1691:         },
bpatel@1686:         {BUG_ID + FS + "typeannos" + FS + "TwoBounds.html",
bpatel@1858:             "
class TwoBounds<K extends " +
bpatel@1691:             "@ClassParamA java.lang.String,V extends @ClassParamB" +
bpatel@1686:             " java.lang.String>"
bpatel@1686:         },
bpatel@1686:         {BUG_ID + FS + "typeannos" + FS + "Complex1.html",
bpatel@1686:             "class Complex1<K extends " +
jjg@1736:             "@ClassParamA java.lang.String & java.lang.Runnable>"
bpatel@1686:         },
bpatel@1686:         {BUG_ID + FS + "typeannos" + FS + "Complex2.html",
bpatel@1686:             "class Complex2<K extends java.lang." +
jjg@1736:             "String & @ClassParamB java.lang.Runnable>"
bpatel@1686:         },
bpatel@1686:         {BUG_ID + FS + "typeannos" + FS + "ComplexBoth.html",
bpatel@1686:             "class ComplexBoth<K extends @ClassParamA java.lang.String & @ClassParamA" +
bpatel@1686:             " java.lang.Runnable>"
bpatel@1686:         },
bpatel@1686: 
bpatel@1691:         // Test for type annotations on fields (Fields.java).
bpatel@1691:         {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html",
bpatel@1691:             "
Parameterized<@FldA java.lang.String," +
bpatel@1691:             "@FldB java.lang.String> bothTypeArgs
" bpatel@1691: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html", bpatel@1691: "
@FldA java.lang.String @FldB [] " +
bpatel@1691:             "array1Deep
" bpatel@1691: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html", bpatel@1691: "
java.lang.String[] @FldB [] array2SecondOld
" bpatel@1691: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html", bpatel@1691: "
@FldD java.lang.String @FldC @FldA" +
bpatel@1691:             " [] @FldC @FldB [] array2Deep
" bpatel@1691: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "ModifiedScoped.html", bpatel@1691: "
public final Parameterized<@FldA " +
bpatel@1691:             "Parameterized<@FldA java.lang.String," +
bpatel@1691:             "@FldB java.lang.String>,@FldB java.lang.String> " +
bpatel@1691:             "nestedParameterized
" bpatel@1691: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "ModifiedScoped.html", bpatel@1691: "
public final @FldA java.lang.String[][] " +
bpatel@1691:             "array2
" bpatel@1691: }, bpatel@1691: bpatel@1686: // Test for type annotations on method return types (MethodReturnType.java). bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html", bpatel@1686: "
public <T> @MRtnA java.lang.String" +
bpatel@1686:             " method()
" bpatel@1686: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html", bpatel@1691: "
@MRtnA java.lang.String @MRtnA [] " +
bpatel@1691:             "@MRtnB [] array2Deep()
" bpatel@1691: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html", bpatel@1691: "
@MRtnA java.lang.String[][] array2()
" bpatel@1691: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "MtdModifiedScoped.html", bpatel@1691: "
public final MtdParameterized<@MRtnA " +
bpatel@1691:             "MtdParameterized<@MRtnA java.lang." +
bpatel@1691:             "String,@MRtnB java.lang.String>,@MRtnB java." +
bpatel@1691:             "lang.String> nestedMtdParameterized()
" bpatel@1691: }, bpatel@1686: bpatel@1686: // Test for type annotations on method type parameters (MethodTypeParameters.java). bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html", bpatel@1686: "
<K extends @MTyParamA java.lang.String>" +
bpatel@1686:             " void methodExtends()
" bpatel@1686: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html", bpatel@1691: "
<K extends @MTyParamA " +
bpatel@1691:             "MtdTyParameterized<@MTyParamB java.lang.String" +
bpatel@1691:             ">> void nestedExtends()
" bpatel@1691: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html", bpatel@1686: "
public final <K extends @MTyParamA " +
bpatel@1686:             "java.lang.String> void methodExtends()
" bpatel@1686: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html", bpatel@1691: "
public final <K extends @MTyParamA " +
bpatel@1691:             "java.lang.String,V extends @MTyParamA " +
bpatel@1691:             "MtdTyParameterized<@MTyParamB java.lang.String" +
bpatel@1691:             ">> void dual()
" bpatel@1691: }, bpatel@1691: bpatel@1691: // Test for type annotations on parameters (Parameters.java). bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "Parameters.html", bpatel@1691: "
void unannotated(" +
bpatel@1691:             "ParaParameterized<java.lang.String,java.lang.String>" +
bpatel@1691:             " a)
" bpatel@1691: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "Parameters.html", bpatel@1691: "
void nestedParaParameterized(" +
bpatel@1691:             "ParaParameterized<@ParamA " +
bpatel@1691:             "ParaParameterized<@ParamA java.lang.String," +
bpatel@1691:             "@ParamB java.lang.String>,@ParamB" +
bpatel@1691:             " java.lang.String> a)
" bpatel@1691: }, bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "Parameters.html", bpatel@1691: "
void array2Deep(@ParamA java.lang.String " +
bpatel@1691:             "@ParamA [] @ParamB [] a)
" bpatel@1691: }, bpatel@1686: bpatel@1686: // Test for type annotations on throws (Throws.java). bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html", bpatel@1686: "
void oneException()" + NL +
jjg@1741:             "           throws @ThrA java.lang.Exception
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html", bpatel@1686: "
void twoExceptions()" + NL +
jjg@1741:             "            throws @ThrA java.lang.RuntimeException," + NL +
jjg@1741:             "                   @ThrA java.lang.Exception
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html", bpatel@1686: "
public final void oneException(java.lang.String a)" + NL +
bpatel@1686:             "                        throws @ThrA java.lang.Exception
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html", bpatel@1686: "
public final void twoExceptions(java.lang.String a)" + NL +
bpatel@1686:             "                         throws @ThrA java.lang.RuntimeException," + NL +
bpatel@1686:             "                                @ThrA java.lang.Exception
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html", bpatel@1686: "
void oneException()" + NL +
jjg@1741:             "           throws @ThrB(value=\"m\") java.lang.Exception
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html", bpatel@1686: "
void twoExceptions()" + NL +
jjg@1741:             "            throws @ThrB(value=\"m\") java.lang.RuntimeException," + NL +
jjg@1741:             "                   @ThrA java.lang.Exception
" bpatel@1686: }, bpatel@1686: bpatel@1691: // Test for type annotations on type parameters (TypeParameters.java). bpatel@1691: {BUG_ID + FS + "typeannos" + FS + "TestMethods.html", bpatel@1691: "
<K,V extends @TyParaA java.lang.String> " +
bpatel@1691:             "void secondAnnotated()
" bpatel@1691: }, bpatel@1691: bpatel@1686: // Test for type annotations on wildcard type (Wildcards.java). bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "BoundTest.html", bpatel@1686: "
void wcExtends(MyList<? extends @WldA" +
bpatel@1686:             " java.lang.String> l)
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "BoundTest.html", bpatel@1686: "
MyList<? super @WldA java.lang.String>" +
bpatel@1686:             " returnWcSuper()
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "BoundWithValue.html", bpatel@1686: "
void wcSuper(MyList<? super @WldB(value=\"m\") java.lang." +
bpatel@1686:             "String> l)
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "BoundWithValue.html", bpatel@1686: "
MyList<? extends @WldB(value=\"m\") java.lang.String" +
bpatel@1686:             "> returnWcExtends()
" bpatel@1686: }, bpatel@1686: bpatel@1686: // Test for receiver annotations (Receivers.java). bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html", bpatel@1686: "
void withException(@RcvrA " +
jjg@1741:             "DefaultUnmodified this)" + NL + "            throws java." +
bpatel@1686:             "lang.Exception
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html", bpatel@1686: "
java.lang.String nonVoid(@RcvrA @RcvrB" +
bpatel@1686:             "(value=\"m\")" +
bpatel@1686:             " DefaultUnmodified this)
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html", bpatel@1686: "
<T extends java.lang.Runnable> void accept(" +
bpatel@1686:             "@RcvrA DefaultUnmodified this," + NL +
jjg@1741:             "                                           T r)" + NL +
jjg@1741:             "                                    throws java.lang.Exception
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "PublicModified.html", bpatel@1686: "
public final java.lang.String nonVoid(" +
bpatel@1686:             "@RcvrA PublicModified this)
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "PublicModified.html", bpatel@1686: "
public final <T extends java.lang.Runnable> " +
bpatel@1686:             "void accept(@RcvrA PublicModified this," + NL +
jjg@1741:             "                                                        T r)" + NL +
jjg@1741:             "                                                 throws java.lang.Exception
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "WithValue.html", bpatel@1686: "
<T extends java.lang.Runnable> void accept(" +
bpatel@1686:             "@RcvrB(" +
bpatel@1686:             "value=\"m\") WithValue this," + NL +
jjg@1741:             "                                           T r)" + NL +
jjg@1741:             "                                    throws java.lang.Exception
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "WithFinal.html", bpatel@1686: "
java.lang.String nonVoid(@RcvrB(value=\"m\") WithFinal" +
bpatel@1686:             " this)
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "WithBody.html", bpatel@1686: "
void field(@RcvrA WithBody this)
" bpatel@1686: }, bpatel@1686: {BUG_ID + FS + "typeannos" + FS + "Generic2.html", bpatel@1686: "
void test2(@RcvrA Generic2<X> this)
" bpatel@1686: } bpatel@1686: }; bpatel@1686: bpatel@1686: /** bpatel@1686: * The entry point of the test. bpatel@1686: * @param args the array of command line arguments. bpatel@1686: */ bpatel@1686: public static void main(String[] args) { bpatel@1686: TestTypeAnnotations tester = new TestTypeAnnotations(); bpatel@1686: run(tester, ARGS, TEST, NEGATED_TEST); bpatel@1686: tester.printSummary(); bpatel@1686: } bpatel@1686: bpatel@1686: /** bpatel@1686: * {@inheritDoc} bpatel@1686: */ bpatel@1686: public String getBugId() { bpatel@1686: return BUG_ID; bpatel@1686: } bpatel@1686: bpatel@1686: /** bpatel@1686: * {@inheritDoc} bpatel@1686: */ bpatel@1686: public String getBugName() { bpatel@1686: return getClass().getName(); bpatel@1686: } bpatel@1686: }