1 /*
   2  * Copyright (c) 2001, 2015, 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  */
  23 
  24 /*
  25  * @test
  26  * @summary Determine if proper warning messages are printed.
  27  * @author jamieh
  28  * @library ../lib
  29  * @modules jdk.javadoc
  30  * @build JavadocTester
  31  * @build TestTagMisuse
  32  * @run main TestTagMisuse
  33  */
  34 public class TestTagMisuse extends JavadocTester {
  35 
  36     /**
  37      * The entry point of the test.
  38      * @param args the array of command line arguments.
  39      * @throws Exception if the test fails
  40      */
  41     public static void main(String... args) throws Exception {
  42         TestTagMisuse tester = new TestTagMisuse();
  43         tester.runTests();
  44     }
  45 
  46     @Test
  47     void test() {
  48         javadoc("-Xdoclint:none",
  49                 "-d", "out",
  50                 testSrc("TestTagMisuse.java"));
  51         checkExit(Exit.OK);
  52 
  53         checkOutput(Output.OUT, true,
  54                 "warning - Tag @param cannot be used in field documentation.",
  55                 "warning - Tag @throws cannot be used in field documentation.",
  56                 "warning - Tag @return cannot be used in constructor documentation."
  57                 /* DCerroneous, "warning - Tag @throws cannot be used in inline documentation."*/);
  58         checkOutput(Output.OUT, false, "DocletAbortException");
  59     }
  60 
  61     /**
  62      * {@throws blah}
  63      * Here is a bad field tag:
  64      * @throws foo
  65      * @param foo.
  66      */
  67     public int field;
  68 
  69     /**
  70      * Here is a bad constructor tag:
  71      * @return blah
  72      */
  73     public TestTagMisuse(){}
  74 
  75     /**
  76      * for @see and {@link}), and ThrowsTag (for @throws).
  77      */
  78     public void thisShouldNotCrash() {}
  79 }