alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (TestTypeAnnotations.java)

This example Java source code file (TestTypeAnnotations.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

bug_id, classexta, classparama, flda, fldb, mrtna, mtyparama, rcvra, string, thra

The TestTypeAnnotations.java Java example source code

/*
 * 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 8026567
 * @summary  Make sure that type annotations are displayed correctly
 * @author   Bhavesh Patel
 * @library  ../lib/
 * @ignore
 * @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 <a href=\"../typeannos/ClassExtA.html\" title=\"annotation " +
            "in typeannos\">@ClassExtA</a> < java.lang.CharSequence, " +
            "<a href=\"../typeannos/ClassExtA.html\" title=\"annotation in " +
            "typeannos\">@ClassExtA</a> <" +
            "<a href=\"../typeannos/ClassExtB.html\" title=\"annotation in " +
            "typeannos\">@ClassExtB</a> java.lang.String>
" }, {BUG_ID + FS + "typeannos" + FS + "MyInterface.html", "extends <a href=\"../typeannos/ClassExtA.html\" title=\"annotation " + "in typeannos\">@ClassExtA</a> java.lang.String>, " + "<a href=\"../typeannos/ClassExtB.html\" title=\"annotation in " + "typeannos\">@ClassExtB</a> java.lang.CharSequence" }, // Test for type annotations on Class Parameters (ClassParameters.java). {BUG_ID + FS + "typeannos" + FS + "ExtendsBound.html", "class <span class=\"typeNameLabel\">ExtendsBound<K extends java.lang.String>" }, {BUG_ID + FS + "typeannos" + FS + "ExtendsGeneric.html", "<pre>class ExtendsGeneric<K extends " + "<a href=\"../typeannos/ClassParamA.html\" title=\"annotation in " + "typeannos\">@ClassParamA</a> <" }, {BUG_ID + FS + "typeannos" + FS + "TwoBounds.html", "<pre>class TwoBounds<K extends " }, {BUG_ID + FS + "typeannos" + FS + "Complex1.html", "class <span class=\"typeNameLabel\">Complex1<K extends " }, {BUG_ID + FS + "typeannos" + FS + "Complex2.html", "class <span class=\"typeNameLabel\">Complex2<K extends java.lang." + "String & <a href=\"../typeannos/ClassParamB.html\" title=\"" + "annotation in typeannos\">@ClassParamB</a> java.lang.Runnable>" }, {BUG_ID + FS + "typeannos" + FS + "ComplexBoth.html", "class <span class=\"typeNameLabel\">ComplexBoth<K extends java.lang.String & " }, // Test for type annotations on fields (Fields.java). {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html", "<pre>< java.lang.String," }, {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html", "<pre> java.lang.String [] " + "array1Deep</pre>" }, {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html", "<pre>java.lang.String[] [] array2SecondOld" }, {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html", "<pre> java.lang.String [] array2Deep" }, {BUG_ID + FS + "typeannos" + FS + "ModifiedScoped.html", "<pre>public final < " + "<a href=\"../typeannos/Parameterized.html\" title=\"class in " + "typeannos\">Parameterized</a>< java.lang.String, java.lang.String> " + "nestedParameterized</pre>" }, {BUG_ID + FS + "typeannos" + FS + "ModifiedScoped.html", "<pre>public final  java.lang.String[][] " + "array2</pre>" }, // Test for type annotations on method return types (MethodReturnType.java). {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html", "<pre>public <T>  java.lang.String" + " method()</pre>" }, {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html", "<pre> java.lang.String [] " }, {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html", "<pre> java.lang.String[][] array2()" }, {BUG_ID + FS + "typeannos" + FS + "MtdModifiedScoped.html", "<pre>public final < " + "<a href=\"../typeannos/MtdParameterized.html\" title=\"class in " + "typeannos\">MtdParameterized</a>< java.lang." + "String,<a href=\"../typeannos/MRtnB.html\" title=\"annotation in " + "typeannos\">@MRtnB</a> java.lang.String>, java." + "lang.String> nestedMtdParameterized()</pre>" }, // Test for type annotations on method type parameters (MethodTypeParameters.java). {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html", "<pre><K extends java.lang.String>" + " void methodExtends()</pre>" }, {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html", "<pre><K extends java.lang.String" + ">> void nestedExtends()</pre>" }, {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html", "<pre>public final <K extends " + "java.lang.String> void methodExtends()</pre>" }, {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html", "<pre>public final <K extends " + "java.lang.String,V extends <a href=\"../typeannos/MTyParamA.html\" " + "title=\"annotation in typeannos\">@MTyParamA</a> java.lang.String" + ">> void dual()</pre>" }, // Test for type annotations on parameters (Parameters.java). {BUG_ID + FS + "typeannos" + FS + "Parameters.html", "<pre>void unannotated( java.lang.String," + "<a href=\"../typeannos/ParamB.html\" title=\"annotation in " + "typeannos\">@ParamB</a> java.lang.String>," }, {BUG_ID + FS + "typeannos" + FS + "Parameters.html", "<pre>void array2Deep( java.lang.String " + "<a href=\"../typeannos/ParamA.html\" title=\"annotation in " + "typeannos\">@ParamA</a> [] [] a)" }, // Test for type annotations on throws (Throws.java). {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html", "<pre>void oneException()" + NL + " throws <a href=\"../typeannos/ThrA.html\" title=\"" + "annotation in typeannos\">@ThrA</a> java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html", "<pre>void twoExceptions()" + NL + " throws <a href=\"../typeannos/ThrA.html\" title=\"" + "annotation in typeannos\">@ThrA</a> java.lang.RuntimeException," + NL + " <a href=\"../typeannos/ThrA.html\" title=\"" + "annotation in typeannos\">@ThrA</a> java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html", "<pre>public final void oneException(java.lang.String a)" + NL + " throws <a href=\"../typeannos/ThrA.html\" " + "title=\"annotation in typeannos\">@ThrA</a> java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html", "<pre>public final void twoExceptions(java.lang.String a)" + NL + " throws <a href=\"../typeannos/ThrA.html\" " + "title=\"annotation in typeannos\">@ThrA</a> java.lang.RuntimeException," + NL + " <a href=\"../typeannos/ThrA.html\" " + "title=\"annotation in typeannos\">@ThrA</a> java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html", "<pre>void oneException()" + NL + " throws <a href=\"../typeannos/ThrB.html\" title=\"" + "annotation in typeannos\">@ThrB</a>(=\"m\") java.lang.Exception" }, {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html", "<pre>void twoExceptions()" + NL + " throws <a href=\"../typeannos/ThrB.html\" title=\"" + "annotation in typeannos\">@ThrB</a>(=\"m\") java.lang.RuntimeException," + NL + " <a href=\"../typeannos/ThrA.html\" title=\"" + "annotation in typeannos\">@ThrA</a> java.lang.Exception" }, // Test for type annotations on type parameters (TypeParameters.java). {BUG_ID + FS + "typeannos" + FS + "TestMethods.html", "<pre><K,V extends java.lang.String> " + "void secondAnnotated()</pre>" }, // Test for type annotations on wildcard type (Wildcards.java). {BUG_ID + FS + "typeannos" + FS + "BoundTest.html", "<pre>void wcExtends(<? extends " }, {BUG_ID + FS + "typeannos" + FS + "BoundTest.html", "<pre><? super java.lang.String>" + " returnWcSuper()</pre>" }, {BUG_ID + FS + "typeannos" + FS + "BoundWithValue.html", "<pre>void wcSuper(<? super (=\"m\") java.lang." + "String> l)</pre>" }, {BUG_ID + FS + "typeannos" + FS + "BoundWithValue.html", "<pre><? extends (=\"m\") java.lang.String" + "> returnWcExtends()</pre>" }, // Test for receiver annotations (Receivers.java). {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html", "<pre>void withException( " + "DefaultUnmodified this)" + NL + " throws java." + "lang.Exception</pre>" }, {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html", "<pre>java.lang.String nonVoid( value=\"m\")" + " DefaultUnmodified this)</pre>" }, {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html", "<pre><T extends java.lang.Runnable> void accept(" + "<a href=\"../typeannos/RcvrA.html\" title=\"annotation in " + "typeannos\">@RcvrA</a> DefaultUnmodified this," + NL + " T r)" + NL + " throws java.lang.Exception</pre>" }, {BUG_ID + FS + "typeannos" + FS + "PublicModified.html", "<pre>public final java.lang.String nonVoid(" }, {BUG_ID + FS + "typeannos" + FS + "PublicModified.html", "<pre>public final <T extends java.lang.Runnable> " + "void accept(<a href=\"../typeannos/RcvrA.html\" title=\"" + "annotation in typeannos\">@RcvrA</a> PublicModified this," + NL + " T r)" + NL + " throws java.lang.Exception</pre>" }, {BUG_ID + FS + "typeannos" + FS + "WithValue.html", "<pre><T extends java.lang.Runnable> void accept(" + "<a href=\"../typeannos/RcvrB.html\" title=\"annotation in " + "typeannos\">@RcvrB</a>(" + "value</a>=\"m\") WithValue this," + NL + " T r)" + NL + " throws java.lang.Exception</pre>" }, {BUG_ID + FS + "typeannos" + FS + "WithFinal.html", "<pre>java.lang.String nonVoid((=\"m\") WithFinal" + " this)</pre>" }, {BUG_ID + FS + "typeannos" + FS + "WithBody.html", "<pre>void field( WithBody this)" }, {BUG_ID + FS + "typeannos" + FS + "Generic2.html", "<pre>void test2( 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(); } }
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.