001: ////////////////////////////////////////////////////////////////////////////////
002: // Test case file for checkstyle.
003: // Created: 2001
004: ////////////////////////////////////////////////////////////////////////////////
005: package com.puppycrawl.tools.checkstyle;
006:
007: import java.io.IOException;
008:
009: // Tests for Javadoc tags.
010: class InputTags1 {
011: // Invalid - should be Javadoc
012: private int mMissingJavadoc;
013:
014: // Invalid - should be Javadoc
015: void method1() {
016: }
017:
018: /** @param unused asd **/
019: void method2() {
020: }
021:
022: /** missing return **/
023: int method3() {
024: return 3;
025: }
026:
027: /**
028: * missing return
029: * @param aOne ignored
030: **/
031: int method4(int aOne) {
032: return aOne;
033: }
034:
035: /** missing throws **/
036: void method5() throws Exception {
037: }
038:
039: /**
040: * @see missing throws
041: * @see need to see tags to avoid shortcut logic
042: **/
043: void method6() throws Exception {
044: }
045:
046: /** @throws WrongException error **/
047: void method7() throws Exception, NullPointerException {
048: }
049:
050: /** missing param **/
051: void method8(int aOne) {
052: }
053:
054: /**
055: * @see missing param
056: * @see need to see tags to avoid shortcut logic
057: **/
058: void method9(int aOne) {
059: }
060:
061: /** @param WrongParam error **/
062: void method10(int aOne, int aTwo) {
063: }
064:
065: /**
066: * @param Unneeded parameter
067: * @return also unneeded
068: **/
069: void method11() {
070: }
071:
072: /**
073: * @return first one
074: * @return duplicate
075: **/
076: int method12() {
077: return 0;
078: }
079:
080: /**
081: * @param aOne
082: * @param aTwo
083: *
084: * This is a multiline piece of javadoc
085: * Unlike the previous one, it actually has content
086: * @param aThree
087: *
088: *
089: * This also has content
090: * @param aFour
091:
092: *
093: * @param aFive
094: **/
095: void method13(int aOne, int aTwo, int aThree, int aFour, int aFive) {
096: }
097:
098: /** @param aOne Perfectly legal **/
099: void method14(int aOne) {
100: }
101:
102: /** @throws java.io.IOException
103: * just to see if this is also legal **/
104: void method14() throws java.io.IOException {
105: }
106:
107: // Test static initialiser
108: static {
109: int x = 1; // should not require any javadoc
110: }
111:
112: // test initialiser
113: {
114: int z = 2; // should not require any javadoc
115: }
116:
117: /** handle where variable declaration over several lines **/
118: private static final int ON_SECOND_LINE = 2;
119:
120: /**
121: * Documenting different causes for the same exception
122: * in separate tags is OK (bug 540384).
123: *
124: * @throws java.io.IOException if A happens
125: * @throws java.io.IOException if B happens
126: **/
127: void method15() throws java.io.IOException {
128: }
129:
130: /** {@inheritDoc} **/
131: public String toString() {
132: return super .toString();
133: }
134:
135: /** getting code coverage up **/
136: static final int serialVersionUID = 666;
137:
138: //**********************************************************************/
139: // Method Name: method16
140: /**
141: * handle the case of an elaborate header surrounding javadoc comments
142: *
143: * @param aOne valid parameter content
144: */
145: //**********************************************************************/
146: void method16(int aOne) {
147: }
148:
149: /**
150: * @throws ThreadDeath although bad practice, should be silently ignored
151: * @throws ArrayStoreException another r/t subclass
152: * @throws IllegalMonitorStateException should be told to remove from throws
153: */
154: void method17() throws IllegalMonitorStateException {
155: }
156:
157: /**
158: * declaring the imported version of an Exception and documenting
159: * the full class name is OK (bug 658805).
160: * @throws java.io.IOException if bad things happen.
161: */
162: void method18() throws IOException {
163: throw new IOException("to make compiler happy");
164: }
165:
166: /**
167: * reverse of bug 658805.
168: * @throws IOException if bad things happen.
169: */
170: void method19() throws java.io.IOException {
171: throw new IOException("to make compiler happy");
172: }
173:
174: /**
175: * Bug 579190, "expected return tag when one is there".
176: *
177: * Linebreaks after return tag should be legal.
178: *
179: * @return
180: * the bug that states that linebreak should be legal
181: */
182: int method20() {
183: return 579190;
184: }
185:
186: /**
187: * Bug XXX, "two tags for the same exception"
188: *
189: * @exception java.io.IOException for some reasons
190: * @exception IOException for another reason
191: */
192: void method21() throws IOException {
193: }
194:
195: /**
196: * RFE 540383, "Unused throws tag for exception subclass"
197: *
198: * @exception IOException for some reasons
199: * @exception java.io.FileNotFoundException for another reasons
200: */
201: void method22() throws IOException {
202: }
203:
204: /**
205: * @exception WrongException exception w/o class info but matched by name
206: */
207: void method23() throws WrongException {
208: }
209:
210: /**
211: * Bug 803577, "allowThrowsTagsForSubclasses/allowMissingThrowsTag interfere"
212: *
213: * no exception tag for IOException, but here is a tag for its subclass.
214: * @exception java.io.FileNotFoundException for another reasons
215: */
216: void method24() throws IOException {
217: }
218:
219: /**
220: * Bug 841942, "ArrayIndexOutOfBounds in JavadocStyle".
221: * @param aParam there is no such param in the method.
222: * The problem should be reported with correct line number.
223: */
224:
225: void method25() {
226: }
227:
228: /** {@inheritDoc} */
229: int method26() {
230: return 0;
231: }
232:
233: /**
234: * {@inheritDoc}
235: * @return something very important.
236: */
237: int method27(int aParam) {
238: return 0;
239: }
240:
241: /**
242: * @return something very important.
243: * {@inheritDoc}
244: */
245: int method28(int aParam) {
246: return 0;
247: }
248:
249: /**
250: * {@inheritDoc}
251: *
252: * @return 1
253: */
254: public int foo(Object _arg) {
255:
256: return 1;
257: }
258: }
259:
260: enum InputTagsEnum {
261: CONSTANT_A,
262:
263: /**
264: *
265: */
266: CONSTANT_B,
267:
268: CONSTANT_C {
269: /**
270: *
271: */
272: public void someMethod() {
273: }
274:
275: public void someOtherMethod() {
276:
277: }
278: }
279: }
280:
281: @interface InputTagsAnnotation {
282: String someField();
283:
284: int A_CONSTANT = 0;
285: /** Some javadoc. */
286: int B_CONSTANT = 1;
287:
288: /** @return This tag is not valid here */
289: String someField2();
290: }
291:
292: /**
293: * Some javadoc.
294: */
295: public class InputTags {
296:
297: /**
298: * Constructor.
299: */
300: public InputTags() {
301: }
302:
303: /**
304: * Sample method.
305: * @param arg1 first argument
306: * @param arg2 second argument
307: * @return java.lang.String the result string
308: * @throws java.lang.Exception in case of problem
309: */
310: public final String myMethod(final String arg1, final Object arg2)
311: throws Exception {
312: return null;
313: }
314: }
315:
316: /**
317: * Added to make this file compilable.
318: */
319: class WrongException extends RuntimeException {
320: }
|