test/com/sun/javadoc/InheritDocForUserTags/DocTest.java

Mon, 16 Sep 2013 14:13:44 +0200

author
jlahoda
date
Mon, 16 Sep 2013 14:13:44 +0200
changeset 2028
4ce8148ffc4f
parent 0
959103a6100f
permissions
-rw-r--r--

8021112: Spurious unchecked warning reported by javac
6480588: No way to suppress deprecation warnings when implementing deprecated interface
Summary: Fixing DeferredLintHandler configuration, so lint warnings are reported with correct @SuppressWarnings settings
Reviewed-by: jjg, vromero

     1 /*
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 /*
    25  * @test
    26  * @bug 8008768
    27  * @summary Using {@inheritDoc} in simple tag defined via -tag fails
    28  * @author Mike Duigou
    29  * @run main DocTest
    30  */
    32 import java.io.*;
    34 /**
    35  * DocTest documentation.
    36  *
    37  * @apiNote DocTest API note.
    38  * @implSpec DocTest implementation spec.
    39  * @implNote DocTest implementation note.
    40  */
    41 public class DocTest {
    42     public static void main(String... args) throws Exception {
    43         String[] javadoc_args = {
    44             "-verbose",
    45             "-d", "DocTest",
    46             "-tag", "apiNote:optcm:<em>API Note</em>",
    47             "-tag", "implSpec:optcm:<em>Implementation Requirements</em>:",
    48             "-tag", "implNote:optcm:<em>Implementation Note</em>:",
    49             "-package",
    50             new File(System.getProperty("test.src"), "DocTest.java").getPath()
    51         };
    53         // javadoc does not report an exit code for an internal exception (!)
    54         // so monitor stderr for stack dumps.
    55         PrintStream prevErr = System.err;
    56         ByteArrayOutputStream err_baos = new ByteArrayOutputStream();
    57         PrintStream err_ps = new PrintStream(err_baos);
    58         System.setErr(err_ps);
    60         int rc;
    61         try {
    62             rc = com.sun.tools.javadoc.Main.execute(javadoc_args);
    63         } finally {
    64             err_ps.close();
    65             System.setErr(prevErr);
    66         }
    68         String err = err_baos.toString();
    69         System.err.println(err);
    71         if (rc != 0)
    72             throw new Exception("javadoc exited with rc=" + rc);
    74         if (err.contains("at com.sun."))
    75             throw new Exception("javadoc output contains stack trace");
    76     }
    78     /**
    79      * DocTest() documentation.
    80      *
    81      * @apiNote DocTest() API note.
    82      * @implSpec DocTest() implementation spec.
    83      * @implNote DocTest() implementation note.
    84      */
    85     public DocTest() {
    86     }
    88     /**
    89      * DocTest.testMethod() documentation.
    90      *
    91      * @apiNote DocTest.testMethod() API note.
    92      * @implSpec DocTest.testMethod() implementation spec.
    93      * @implNote DocTest.testMethod() implementation note.
    94      */
    95     public void testMethod() {
    96     }
    97 }
    99 /**
   100  * DocTestWithTags documentation.
   101  *
   102  * @apiNote DocTestWithTags API note.
   103  * <pre>
   104  *    DocTestWithTags API note code sample.
   105  * </pre>
   106  * @implSpec DocTestWithTags implementation spec.
   107  * <pre>
   108  *    DocTestWithTags implementation spec code sample.
   109  * </pre>
   110  * @implNote DocTestWithTags implementation note.
   111  * <pre>
   112  *    DocTestWithTags implementation note code sample.
   113  * </pre>
   114  */
   115 class DocTestWithTags {
   117     /**
   118      * DocTestWithTags() documentation.
   119      *
   120      * @apiNote DocTestWithTags() API note.
   121      * <pre>
   122      *    DocTestWithTags() API note code sample.
   123      * </pre>
   124      * @implSpec DocTestWithTags() implementation spec.
   125      * <pre>
   126      *    DocTestWithTags() implementation spec code sample.
   127      * </pre>
   128      * @implNote DocTest() implementation note.
   129      * <pre>
   130      *    DocTest() implementation note code sample.
   131      * </pre>
   132      */
   133     public DocTestWithTags() {
   134     }
   136     /**
   137      * DocTest.testMethod() documentation.
   138      *
   139      * @apiNote DocTestWithTags.testMethod() API note.
   140      * <pre>
   141      *    DocTestWithTags.testMethod() API note code sample.
   142      * </pre>
   143      * @implSpec DocTestWithTags.testMethod() implementation spec.
   144      * <pre>
   145      *    DocTestWithTags.testMethod() API implementation spec code sample.
   146      * </pre>
   147      * @implNote DocTest.testMethod() implementation note.
   148      * <pre>
   149      *    DocTest.testMethod() API implementation code sample.
   150      * </pre>
   151      */
   152     public void testMethod() {
   153     }
   154 }
   156 class MinimallyExtendsDocTest extends DocTest {
   157 }
   159 /**
   160  * SimpleExtendsDocTest documentation.
   161  */
   162 class SimpleExtendsDocTest extends DocTest {
   164     /**
   165      * SimpleExtendsDocTest() documentation.
   166      */
   167     public SimpleExtendsDocTest() {
   169     }
   171     /**
   172      * SimpleExtendsDocTest.testMethod() documenation.
   173      */
   174     @java.lang.Override
   175     public void testMethod() {
   176     }
   177 }
   179 /**
   180  * {@inheritDoc}
   181  */
   182 class SimpleInheritDocDocTest extends DocTest {
   184     /**
   185      * {@inheritDoc}
   186      */
   187     public SimpleInheritDocDocTest() {
   188     }
   190     /**
   191      * {@inheritDoc}
   192      */
   193     @java.lang.Override
   194     public void testMethod() {
   195     }
   196 }
   198 /**
   199  * {@inheritDoc}
   200  *
   201  * @apiNote {@inheritDoc}
   202  * @implSpec {@inheritDoc}
   203  * @implNote {@inheritDoc}
   204  */
   205 class FullInheritDocDocTest extends DocTest {
   207     /**
   208      * {@inheritDoc}
   209      *
   210      * @apiNote {@inheritDoc}
   211      * @implSpec {@inheritDoc}
   212      * @implNote {@inheritDoc}
   213      */
   214     public FullInheritDocDocTest() {
   216     }
   218     /**
   219      * {@inheritDoc}
   220      *
   221      * @apiNote {@inheritDoc}
   222      * @implSpec {@inheritDoc}
   223      * @implNote {@inheritDoc}
   224      */
   225     @java.lang.Override
   226     public void testMethod() {
   227     }
   228 }
   230 /**
   231  * {@inheritDoc} and FullInheritDocPlusDocTest documentation.
   232  *
   233  * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest API note.
   234  * @implNote {@inheritDoc} and FullInheritDocPlusDocTest implementation specification.
   235  * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest implementation note.
   236  */
   237 class FullInheritDocPlusDocTest extends DocTest {
   239     /**
   240      * {@inheritDoc} and FullInheritDocPlusDocTest() documentation.
   241      *
   242      * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest() API note.
   243      * @implNote {@inheritDoc} and FullInheritDocPlusDocTest() implementation specification.
   244      * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest() implementation note.
   245      */
   246     public FullInheritDocPlusDocTest() {
   248     }
   250     /**
   251      * {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() documentation.
   252      *
   253      * @implSpec {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() API note.
   254      * @implNote {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() implementation specification.
   255      * @apiNote {@inheritDoc} and FullInheritDocPlusDocTest.testMethod() implementation note.
   256      */
   257     @java.lang.Override
   258     public void testMethod() {
   259     }
   260 }

mercurial