1 /******************************************************************************* 2 * Copyright (c) 2000, 2014 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.jdt.core.tests.compiler.regression; 15 16 import java.util.Map; 17 18 import junit.framework.Test; 19 20 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; 21 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; 22 23 @SuppressWarnings({ "unchecked", "rawtypes" }) 24 public class JavadocTestForField extends JavadocTest { JavadocTestForField(String name)25 public JavadocTestForField(String name) { 26 super(name); 27 } javadocTestClass()28 public static Class javadocTestClass() { 29 return JavadocTestForField.class; 30 } suite()31 public static Test suite() { 32 return buildAllCompliancesTestSuite(javadocTestClass()); 33 } 34 static { // Use this static to initialize testNames (String[]) , testRange (int[2]), testNumbers (int[]) 35 } 36 37 @Override getCompilerOptions()38 protected Map getCompilerOptions() { 39 Map options = super.getCompilerOptions(); 40 options.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.ERROR); 41 options.put(CompilerOptions.OPTION_ReportInvalidJavadocTagsVisibility, CompilerOptions.PRIVATE); 42 options.put(CompilerOptions.OPTION_ReportMissingJavadocTags, CompilerOptions.ERROR); 43 options.put(CompilerOptions.OPTION_ReportMissingJavadocTagsVisibility, CompilerOptions.PRIVATE); 44 options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); 45 return options; 46 } 47 48 /* 49 * (non-Javadoc) Test @param tag 50 */ test001()51 public void test001() { 52 this.runConformTest( 53 new String[] { 54 "X.java", 55 "public class X {\n" 56 + "/**\n" 57 + " * Valid field javadoc\n" 58 + " * @author ffr\n" 59 + " */\n" 60 + " public int x;\n" 61 + "}\n" }); 62 } 63 test002()64 public void test002() { 65 this.runNegativeTest( 66 new String[] { 67 "X.java", 68 "public class X {\n" 69 + " /**\n" 70 + " * Invalid field javadoc\n" 71 + " * @param x Invalid tag\n" 72 + " */\n" 73 + " public int x;\n" 74 + "}\n" }, 75 "----------\n" 76 + "1. ERROR in X.java (at line 4)\n" 77 + " * @param x Invalid tag\n" 78 + " ^^^^^\n" 79 + "Javadoc: Unexpected tag\n" 80 + "----------\n", 81 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); 82 } 83 test003()84 public void test003() { 85 this.runNegativeTest( 86 new String[] { 87 "X.java", 88 "public class X {\n" 89 + " /**\n" 90 + " * Invalid field javadoc\n" 91 + " * @throws NullPointerException Invalid tag\n" 92 + " */\n" 93 + " public int x;\n" 94 + "}\n" }, 95 "----------\n" 96 + "1. ERROR in X.java (at line 4)\n" 97 + " * @throws NullPointerException Invalid tag\n" 98 + " ^^^^^^\n" 99 + "Javadoc: Unexpected tag\n" 100 + "----------\n", 101 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); 102 } 103 test004()104 public void test004() { 105 this.runNegativeTest( 106 new String[] { 107 "X.java", 108 "public class X {\n" 109 + " /**\n" 110 + " * Invalid field javadoc\n" 111 + " * @exception NullPointerException Invalid tag\n" 112 + " */\n" 113 + " public int x;\n" 114 + "}\n" }, 115 "----------\n" 116 + "1. ERROR in X.java (at line 4)\n" 117 + " * @exception NullPointerException Invalid tag\n" 118 + " ^^^^^^^^^\n" 119 + "Javadoc: Unexpected tag\n" 120 + "----------\n", 121 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); 122 } 123 test005()124 public void test005() { 125 this.runNegativeTest( 126 new String[] { 127 "X.java", 128 "public class X {\n" 129 + " /**\n" 130 + " * Invalid class javadoc\n" 131 + " * @return Invalid tag\n" 132 + " */\n" 133 + " public int x;\n" 134 + "}\n" }, 135 "----------\n" 136 + "1. ERROR in X.java (at line 4)\n" 137 + " * @return Invalid tag\n" 138 + " ^^^^^^\n" 139 + "Javadoc: Unexpected tag\n" 140 + "----------\n", 141 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); 142 } 143 test006()144 public void test006() { 145 this.runNegativeTest( 146 new String[] { 147 "X.java", 148 "public class X {\n" 149 + " /**\n" 150 + " * Invalid class javadoc\n" 151 + " * @exception NullPointerException Invalid tag\n" 152 + " * @throws NullPointerException Invalid tag\n" 153 + " * @return Invalid tag\n" 154 + " * @param x Invalid tag\n" 155 + " */\n" 156 + " public int x;\n" 157 + "}\n" }, 158 "----------\n" 159 + "1. ERROR in X.java (at line 4)\n" 160 + " * @exception NullPointerException Invalid tag\n" 161 + " ^^^^^^^^^\n" 162 + "Javadoc: Unexpected tag\n" 163 + "----------\n" 164 + "2. ERROR in X.java (at line 5)\n" 165 + " * @throws NullPointerException Invalid tag\n" 166 + " ^^^^^^\n" 167 + "Javadoc: Unexpected tag\n" 168 + "----------\n" 169 + "3. ERROR in X.java (at line 6)\n" 170 + " * @return Invalid tag\n" 171 + " ^^^^^^\n" 172 + "Javadoc: Unexpected tag\n" 173 + "----------\n" 174 + "4. ERROR in X.java (at line 7)\n" 175 + " * @param x Invalid tag\n" 176 + " ^^^^^\n" 177 + "Javadoc: Unexpected tag\n" 178 + "----------\n", 179 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); 180 } 181 /* 182 * (non-Javadoc) 183 * Test @deprecated tag 184 */ test007()185 public void test007() { 186 this.runConformTest( 187 true, 188 new String[] { 189 "X.java", 190 "public class X {\n" 191 + " int x;\n" 192 + " {\n" 193 + " x=(new Z()).z;\n" 194 + " }\n" 195 + "}\n", 196 "Z.java", 197 "public class Z {\n" 198 + " /** \n" 199 + " * \n" 200 + " * ** ** ** ** @deprecated */\n" 201 + " public int z;\n" 202 + "}\n", 203 }, 204 "----------\n" 205 + "1. WARNING in X.java (at line 4)\n" 206 + " x=(new Z()).z;\n" 207 + " ^\n" 208 + "The field Z.z is deprecated\n" 209 + "----------\n", 210 null, null, JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings); 211 } 212 test008()213 public void test008() { 214 this.runNegativeTest( 215 new String[] { 216 "X.java", 217 "public class X {\n" 218 + " int x;\n" 219 + " {\n" 220 + " x=(new Z()).z;\n" 221 + " }\n" 222 + "}\n", 223 "Z.java", 224 "public class Z {\n" 225 + " /** \n" 226 + " * Invalid tags with deprecation\n" 227 + " *\n" 228 + " * @param x\n" 229 + " * @return\n" 230 + " * @throws NullPointerException\n" 231 + " * @exception IllegalArgumentException\n" 232 + " * @see X\n" 233 + " * @deprecated\n" 234 + " */\n" 235 + " public int z;\n" 236 + "}\n", 237 }, 238 "----------\n" 239 + "1. WARNING in X.java (at line 4)\n" 240 + " x=(new Z()).z;\n" 241 + " ^\n" 242 + "The field Z.z is deprecated\n" 243 + "----------\n" 244 + "----------\n" 245 + "1. ERROR in Z.java (at line 5)\n" 246 + " * @param x\n" 247 + " ^^^^^\n" 248 + "Javadoc: Unexpected tag\n" 249 + "----------\n" 250 + "2. ERROR in Z.java (at line 6)\n" 251 + " * @return\n" 252 + " ^^^^^^\n" 253 + "Javadoc: Unexpected tag\n" 254 + "----------\n" 255 + "3. ERROR in Z.java (at line 7)\n" 256 + " * @throws NullPointerException\n" 257 + " ^^^^^^\n" 258 + "Javadoc: Unexpected tag\n" 259 + "----------\n" 260 + "4. ERROR in Z.java (at line 8)\n" 261 + " * @exception IllegalArgumentException\n" 262 + " ^^^^^^^^^\n" 263 + "Javadoc: Unexpected tag\n" 264 + "----------\n", 265 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); 266 } 267 268 /* 269 * (non-Javadoc) 270 * Test @see tag 271 */ 272 // String references test010()273 public void test010() { 274 this.runNegativeTest( 275 new String[] { 276 "X.java", 277 "public class X {\n" 278 + " /**\n" 279 + " * Invalid string references \n" 280 + " *\n" 281 + " * @see \"unterminated string\n" 282 + " * @see \"invalid\" no text allowed after the string\n" 283 + " */\n" 284 + " public int x;\n" 285 + "}\n" }, 286 "----------\n" 287 + "1. ERROR in X.java (at line 5)\n" 288 + " * @see \"unterminated string\n" 289 + " ^^^^^^^^^^^^^^^^^^^^\n" 290 + "Javadoc: Invalid reference\n" 291 + "----------\n" 292 + "2. ERROR in X.java (at line 6)\n" 293 + " * @see \"invalid\" no text allowed after the string\n" 294 + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" 295 + "Javadoc: Unexpected text\n" 296 + "----------\n", 297 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); 298 } 299 test011()300 public void test011() { 301 this.runConformTest( 302 new String[] { 303 "X.java", 304 "public class X {\n" 305 + " /**\n" 306 + " * Valid string references \n" 307 + " *\n" 308 + " * @see \"Valid normal string\"\n" 309 + " * @see \"Valid \\\"string containing\\\" \\\"double-quote\\\"\"\n" 310 + " */\n" 311 + " public int x;\n" 312 + "}\n" }); 313 } 314 315 // URL Link references test012()316 public void test012() { 317 this.runNegativeTest( 318 new String[] { 319 "X.java", 320 "public class X {\n" 321 + " /**\n" 322 + " * Invalid URL link references \n" 323 + " *\n" 324 + " * @see <a href=\"invalid\">invalid</\n" 325 + " * @see <a href=\"invalid\">invalid</a> no text allowed after the href\n" 326 + " */\n" 327 + " public int x;\n" 328 + "}\n" }, 329 "----------\n" 330 + "1. ERROR in X.java (at line 5)\n" 331 + " * @see <a href=\"invalid\">invalid</\n" 332 + " ^^\n" 333 + "Javadoc: Malformed link reference\n" 334 + "----------\n" 335 + "2. ERROR in X.java (at line 6)\n" 336 + " * @see <a href=\"invalid\">invalid</a> no text allowed after the href\n" 337 + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" 338 + "Javadoc: Unexpected text\n" 339 + "----------\n", 340 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); 341 } 342 test013()343 public void test013() { 344 this.runConformTest( 345 new String[] { 346 "X.java", 347 "public class X {\n" 348 + " /**\n" 349 + " * Valid URL link references \n" 350 + " *\n" 351 + " * @see <A HREF = \"http://download.oracle.com/javase/6/docs/technotes/tools/windows/javadoc.html\">Valid URL link reference</A>\n" 352 + " */\n" 353 + " public int x;\n" 354 + "}\n" }); 355 } 356 357 // @see Classes references test020()358 public void test020() { 359 runConformReferenceTest( 360 new String[] { 361 "test/X.java", 362 "package test;\n" 363 + "public class X {\n" 364 + " /**\n" 365 + " * Valid local classes references \n" 366 + " *\n" 367 + " * @see Visibility Valid ref: local class \n" 368 + " * @see Visibility.VcPublic Valid ref: visible inner class of local class \n" 369 + " * @see AbstractVisibility.AvcPublic Valid ref: visible inherited inner class of local class \n" 370 + " * @see test.Visibility Valid ref: local class \n" 371 + " * @see test.Visibility.VcPublic Valid ref: visible inner class of local class \n" 372 + " * @see test.AbstractVisibility.AvcPublic Valid ref: visible inherited inner class of local class \n" 373 + " */\n" 374 + " public int x;\n" 375 + "}\n" }); 376 } 377 test021()378 public void test021() { 379 this.runNegativeReferenceTest( 380 new String[] { 381 "test/X.java", 382 "package test;\n" 383 + "public class X {\n" 384 + " /**\n" 385 + " * Invalid local classes references \n" 386 + " *\n" 387 + " * @see Visibility.VcPrivate Invalid ref: non visible inner class of local class \n" 388 + " * @see Visibility.AvcPrivate Invalid ref: non visible inherited inner class of local class \n" 389 + " * @see test.Visibility.VcPrivate Invalid ref: non visible inner class of local class \n" 390 + " * @see test.Visibility.AvcPrivate Invalid ref: non visible inherited inner class of local class \n" 391 + " * @see Unknown Invalid ref: unknown class \n" 392 + " */\n" 393 + " public int x;\n" 394 + "}\n" }, 395 "----------\n" 396 + "1. ERROR in test\\X.java (at line 6)\n" 397 + " * @see Visibility.VcPrivate Invalid ref: non visible inner class of local class \n" 398 + " ^^^^^^^^^^^^^^^^^^^^\n" 399 + "Javadoc: The type Visibility.VcPrivate is not visible\n" 400 + "----------\n" 401 + "2. ERROR in test\\X.java (at line 7)\n" 402 + " * @see Visibility.AvcPrivate Invalid ref: non visible inherited inner class of local class \n" 403 + " ^^^^^^^^^^^^^^^^^^^^^\n" 404 + "Javadoc: The type Visibility.AvcPrivate is not visible\n" 405 + "----------\n" 406 + "3. ERROR in test\\X.java (at line 8)\n" 407 + " * @see test.Visibility.VcPrivate Invalid ref: non visible inner class of local class \n" 408 + " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" 409 + "Javadoc: The type test.Visibility.VcPrivate is not visible\n" 410 + "----------\n" 411 + "4. ERROR in test\\X.java (at line 9)\n" 412 + " * @see test.Visibility.AvcPrivate Invalid ref: non visible inherited inner class of local class \n" 413 + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" 414 + "Javadoc: The type test.Visibility.AvcPrivate is not visible\n" 415 + "----------\n" 416 + "5. ERROR in test\\X.java (at line 10)\n" 417 + " * @see Unknown Invalid ref: unknown class \n" 418 + " ^^^^^^^\n" 419 + "Javadoc: Unknown cannot be resolved to a type\n" 420 + "----------\n"); 421 } 422 test022()423 public void test022() { 424 runConformReferenceTest( 425 new String[] { 426 "test/X.java", 427 "package test;\n" + 428 "import test.copy.*;\n" + 429 "public class X {\n" + 430 " /**\n" + 431 " * Valid external classes references \n" + 432 " *\n" + 433 " * @see VisibilityPublic Valid ref: visible class through import => no warning on import\n" + 434 // Inner classes are not visible in generated documentation 435 //" * @see VisibilityPublic.VpPublic Valid ref: visible inner class in visible class \n" + 436 " */\n" + 437 " public int x;\n" + 438 "}\n" 439 } 440 ); 441 } 442 test023()443 public void test023() { 444 this.runNegativeReferenceTest( 445 new String[] { 446 "test/X.java", 447 "package test;\n" 448 + "import test.copy.*;\n" 449 + "public class X {\n" 450 + " /**\n" 451 + " * Invalid external classes references \n" 452 + " *\n" 453 + " * @see VisibilityPackage Invalid ref: non visible class \n" 454 + " * @see VisibilityPublic.VpPrivate Invalid ref: non visible inner class in visible class \n" 455 + " */\n" 456 + " public int x;\n" 457 + "}\n" }, 458 "----------\n" 459 + "1. ERROR in test\\X.java (at line 7)\n" 460 + " * @see VisibilityPackage Invalid ref: non visible class \n" 461 + " ^^^^^^^^^^^^^^^^^\n" 462 + "Javadoc: The type VisibilityPackage is not visible\n" 463 + "----------\n" 464 + "2. ERROR in test\\X.java (at line 8)\n" 465 + " * @see VisibilityPublic.VpPrivate Invalid ref: non visible inner class in visible class \n" 466 + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" 467 + "Javadoc: The type VisibilityPublic.VpPrivate is not visible\n" 468 + "----------\n"); 469 } 470 test024()471 public void test024() { 472 runConformReferenceTest( 473 new String[] { 474 "test/X.java", 475 "package test;\n" + 476 "public class X {\n" + 477 " /**\n" + 478 " * Valid external classes references \n" + 479 " *\n" + 480 " * @see test.copy.VisibilityPublic Valid ref: visible class through import => no warning on import\n" + 481 // Inner classes are not visible in generated documentation 482 //" * @see test.copy.VisibilityPublic.VpPublic Valid ref: visible inner class in visible class \n" + 483 " */\n" + 484 " public int x;\n" + 485 "}\n" 486 } 487 ); 488 } 489 490 // @see Field references test030()491 public void test030() { 492 runConformReferenceTest( 493 new String[] { 494 "test/X.java", 495 "package test;\n" 496 + "public class X {\n" 497 + " /**\n" 498 + " * Valid local class field references\n" 499 + " *\n" 500 + " * @see #str Valid ref: accessible field\n" 501 + " * @see Visibility#vf_public Valid ref: visible field\n" 502 + " * @see Visibility.VcPublic#vf_public Valid ref: visible field in visible inner class\n" 503 + " */\n" 504 + " public int x;\n" 505 + " public String str;\n" 506 + "}\n" }); 507 } 508 test031()509 public void test031() { 510 this.runNegativeReferenceTest( 511 new String[] { 512 "test/X.java", 513 "package test;\n" 514 + "public class X {\n" 515 + " /**\n" 516 + " * Invalid local class field references\n" 517 + " *\n" 518 + " * @see #str Invalid ref: non existent field\n" 519 + " * @see Visibility#unknown Invalid ref: non existent field\n" 520 + " * @see Visibility#vf_private Invalid ref: non visible field\n" 521 + " * @see Visibility.VcPrivate#unknown Invalid ref: non visible inner class (non existent field)\n" 522 + " * @see Visibility.VcPublic#unknown Invalid ref: non existent field in visible inner class\n" 523 + " * @see Visibility.VcPublic#vf_private Invalid ref: non visible field in visible inner class\n" 524 + " */\n" 525 + " public int x;\n" 526 + "}\n" }, 527 "----------\n" 528 + "1. ERROR in test\\X.java (at line 6)\n" 529 + " * @see #str Invalid ref: non existent field\n" 530 + " ^^^\n" 531 + "Javadoc: str cannot be resolved or is not a field\n" 532 + "----------\n" 533 + "2. ERROR in test\\X.java (at line 7)\n" 534 + " * @see Visibility#unknown Invalid ref: non existent field\n" 535 + " ^^^^^^^\n" 536 + "Javadoc: unknown cannot be resolved or is not a field\n" 537 + "----------\n" 538 + "3. ERROR in test\\X.java (at line 8)\n" 539 + " * @see Visibility#vf_private Invalid ref: non visible field\n" 540 + " ^^^^^^^^^^\n" 541 + "Javadoc: The field vf_private is not visible\n" 542 + "----------\n" 543 + "4. ERROR in test\\X.java (at line 9)\n" 544 + " * @see Visibility.VcPrivate#unknown Invalid ref: non visible inner class (non existent field)\n" 545 + " ^^^^^^^^^^^^^^^^^^^^\n" 546 + "Javadoc: The type Visibility.VcPrivate is not visible\n" 547 + "----------\n" 548 + "5. ERROR in test\\X.java (at line 10)\n" 549 + " * @see Visibility.VcPublic#unknown Invalid ref: non existent field in visible inner class\n" 550 + " ^^^^^^^\n" 551 + "Javadoc: unknown cannot be resolved or is not a field\n" 552 + "----------\n" 553 + "6. ERROR in test\\X.java (at line 11)\n" 554 + " * @see Visibility.VcPublic#vf_private Invalid ref: non visible field in visible inner class\n" 555 + " ^^^^^^^^^^\n" 556 + "Javadoc: The field vf_private is not visible\n" 557 + "----------\n"); 558 } 559 test032()560 public void test032() { 561 runConformReferenceTest( 562 new String[] { 563 "test/X.java", 564 "package test;\n" + 565 "import test.copy.*;\n" + 566 "public class X {\n" + 567 " /**\n" + 568 " * Invalid other package non visible class fields references\n" + 569 " *\n" + 570 " * @see VisibilityPublic#vf_public Valid ref to not visible field of other package class\n" + 571 " * @see test.copy.VisibilityPublic.VpPublic#vf_public Valid ref to not visible field of other package public inner class\n" + 572 " */\n" + 573 " public int x;\n" + 574 "}\n" 575 } 576 ); 577 } 578 test033()579 public void test033() { 580 this.runNegativeReferenceTest( 581 new String[] { 582 "test/X.java", 583 "package test;\n" 584 + "import test.copy.*;\n" 585 + "public class X {\n" 586 + " /**\n" 587 + " * Invalid other package non visible class fields references\n" 588 + " *\n" 589 + " * @see VisibilityPackage#unknown Invalid ref: non visible class (non existent field)\n" 590 + " * @see VisibilityPublic#unknown Invalid ref to non existent field of other package class\n" 591 + " * @see VisibilityPublic#vf_private Invalid ref to not visible field of other package class\n" 592 + " * @see VisibilityPublic.VpPrivate#unknown Invalid ref to a non visible other package private inner class (non existent field)\n" 593 + " * @see VisibilityPublic.VpPublic#unknown Invalid ref to non existent field of other package public inner class\n" 594 + " * @see VisibilityPublic.VpPublic#vf_private Invalid ref to not visible field of other package public inner class\n" 595 + " */\n" 596 + " public int x;\n" 597 + "}\n" }, 598 "----------\n" 599 + "1. ERROR in test\\X.java (at line 7)\n" 600 + " * @see VisibilityPackage#unknown Invalid ref: non visible class (non existent field)\n" 601 + " ^^^^^^^^^^^^^^^^^\n" 602 + "Javadoc: The type VisibilityPackage is not visible\n" 603 + "----------\n" 604 + "2. ERROR in test\\X.java (at line 8)\n" 605 + " * @see VisibilityPublic#unknown Invalid ref to non existent field of other package class\n" 606 + " ^^^^^^^\n" 607 + "Javadoc: unknown cannot be resolved or is not a field\n" 608 + "----------\n" 609 + "3. ERROR in test\\X.java (at line 9)\n" 610 + " * @see VisibilityPublic#vf_private Invalid ref to not visible field of other package class\n" 611 + " ^^^^^^^^^^\n" 612 + "Javadoc: The field vf_private is not visible\n" 613 + "----------\n" 614 + "4. ERROR in test\\X.java (at line 10)\n" 615 + " * @see VisibilityPublic.VpPrivate#unknown Invalid ref to a non visible other package private inner class (non existent field)\n" 616 + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n" 617 + "Javadoc: The type VisibilityPublic.VpPrivate is not visible\n" 618 + "----------\n" 619 + "5. ERROR in test\\X.java (at line 11)\n" 620 + " * @see VisibilityPublic.VpPublic#unknown Invalid ref to non existent field of other package public inner class\n" 621 + " ^^^^^^^\n" 622 + "Javadoc: unknown cannot be resolved or is not a field\n" 623 + "----------\n" 624 + "6. ERROR in test\\X.java (at line 12)\n" 625 + " * @see VisibilityPublic.VpPublic#vf_private Invalid ref to not visible field of other package public inner class\n" 626 + " ^^^^^^^^^^\n" 627 + "Javadoc: The field vf_private is not visible\n" 628 + "----------\n"); 629 } 630 631 // @see method references test040()632 public void test040() { 633 this.runConformTest( 634 new String[] { 635 "X.java", 636 "import java.util.Vector;\n" 637 + "public class X {\n" 638 + " /**\n" 639 + " * Valid local methods references with array\n" 640 + " * \n" 641 + " * @see #smr_foo(char[] array, int[][] matrix, String[][][] dim, Vector[][][][] extra) Valid local method reference\n" 642 + " * @see #smr_foo(char[], int[][], String[][][], Vector[][][][]) Valid local method reference\n" 643 + " * @see #smr_foo(char[],int[][],java.lang.String[][][],java.util.Vector[][][][]) Valid local method reference\n" 644 + " */ \n" 645 + " public int x;\n" 646 + "\n" 647 + " // Empty methods definition for reference\n" 648 + " public void smr_foo(char[] array, int[][] matrix, String[][][] dim, Vector[][][][] extra) {\n" 649 + " }\n" 650 + "}\n" }); 651 } 652 test041()653 public void test041() { 654 this.runNegativeTest( 655 new String[] { 656 "X.java", 657 "import java.util.Vector;\n" 658 + "public class X {\n" 659 + " /**\n" 660 + " * Invalid local methods references with array (non applicable arrays)\n" 661 + " * \n" 662 + " * @see #smr_foo(char , int[][], String[][][], Vector[][][][]) Invalid ref: invalid arguments declaration\n" 663 + " */ \n" 664 + " public int x;\n" 665 + "\n" 666 + " // Empty methods definition for reference\n" 667 + " public void smr_foo(char[] array, int[][] matrix, String[][][] dim, Vector[][][][] extra) {\n" 668 + " }\n" 669 + "}\n" }, 670 "----------\n" 671 + "1. ERROR in X.java (at line 6)\n" 672 + " * @see #smr_foo(char , int[][], String[][][], Vector[][][][]) Invalid ref: invalid arguments declaration\n" 673 + " ^^^^^^^\n" 674 + "Javadoc: The method smr_foo(char[], int[][], String[][][], Vector[][][][]) in the type X is not applicable for the arguments (char, int[][], String[][][], Vector[][][][])\n" 675 + "----------\n", 676 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); 677 } 678 test042()679 public void test042() { 680 this.runConformTest( 681 new String[] { 682 "X.java", 683 "import java.util.Vector;\n" 684 + "public class X {\n" 685 + " /**\n" 686 + " * Valid local methods references\n" 687 + " * \n" 688 + " * @see #smr_foo() Valid local method reference\n" 689 + " * @see #smr_foo(boolean a1,int a2,byte a3,short a4,char a5,long a6,float a7,double a8) Valid local method reference\n" 690 + " * @see #smr_foo(java.lang.String, java.lang.String, int) Valid local method reference \n" 691 + " * @see #smr_foo(java.util.Hashtable a, Vector b, boolean c) Valid local method reference\n" 692 + " */ \n" 693 + " public int x;\n" 694 + "\n" 695 + " // Empty methods definition for reference\n" 696 + " public void smr_foo() {\n" 697 + " }\n" 698 + " public void smr_foo(boolean b, int i, byte y, short s, char c, long l, float f, double d) {\n" 699 + " }\n" 700 + " public void smr_foo(String str1, java.lang.String str2, int i) {\n" 701 + " }\n" 702 + " public void smr_foo(java.util.Hashtable h, java.util.Vector v, boolean b) {\n" 703 + " }\n" 704 + "}\n" }); 705 } 706 test043()707 public void test043() { 708 this.runNegativeTest( 709 new String[] { 710 "X.java", 711 "public class X {\n" 712 + " /**\n" 713 + " * Invalid local methods references\n" 714 + " * \n" 715 + " * @see #unknown() Invalid ref: undefined local method reference\n" 716 + " */ \n" 717 + " public int x;\n" 718 + "\n" 719 + " // Empty methods definition for reference\n" 720 + " public void smr_foo() {\n" 721 + " }\n" 722 + "}\n" }, 723 "----------\n" 724 + "1. ERROR in X.java (at line 5)\n" 725 + " * @see #unknown() Invalid ref: undefined local method reference\n" 726 + " ^^^^^^^\n" 727 + "Javadoc: The method unknown() is undefined for the type X\n" 728 + "----------\n", 729 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); 730 } 731 test044()732 public void test044() { 733 this.runNegativeTest( 734 new String[] { 735 "X.java", 736 "public class X {\n" 737 + " /**\n" 738 + " * Invalid local methods references\n" 739 + " * \n" 740 + " * @see #smr_foo(float, long, char, short, byte, int, boolean) Invalid ref: local method not applicable\n" 741 + " * @see #smr_foo(String, String, int, String) Invalid ref: local method not applicable\n" 742 + " * @see #smr_foo(boolean) Invalid ref: local method not applicable\n" 743 + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" 744 + " */ \n" 745 + " public int x;\n" 746 + "\n" 747 + " // Empty methods definition for reference\n" 748 + " public void smr_foo(boolean b, int i, byte y, short s, char c, long l, float f, double d) {\n" 749 + " }\n" 750 + " public void smr_foo(String str1, java.lang.String str2, int i) {\n" 751 + " }\n" 752 + " public void smr_foo(java.util.Hashtable h, java.util.Vector v, boolean b) {\n" 753 + " }\n" 754 + "}\n" }, 755 "----------\n" 756 + "1. ERROR in X.java (at line 5)\n" 757 + " * @see #smr_foo(float, long, char, short, byte, int, boolean) Invalid ref: local method not applicable\n" 758 + " ^^^^^^^\n" 759 + "Javadoc: The method smr_foo(boolean, int, byte, short, char, long, float, double) in the type X is not applicable for the arguments (float, long, char, short, byte, int, boolean)\n" 760 + "----------\n" 761 + "2. ERROR in X.java (at line 6)\n" 762 + " * @see #smr_foo(String, String, int, String) Invalid ref: local method not applicable\n" 763 + " ^^^^^^^\n" 764 + "Javadoc: The method smr_foo(String, String, int) in the type X is not applicable for the arguments (String, String, int, String)\n" 765 + "----------\n" 766 + "3. ERROR in X.java (at line 7)\n" 767 + " * @see #smr_foo(boolean) Invalid ref: local method not applicable\n" 768 + " ^^^^^^^\n" 769 + "Javadoc: The method smr_foo(boolean, int, byte, short, char, long, float, double) in the type X is not applicable for the arguments (boolean)\n" 770 + "----------\n" 771 + "4. ERROR in X.java (at line 8)\n" 772 + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" 773 + " ^^^^^^^^^\n" 774 + "Javadoc: Hashtable cannot be resolved to a type\n" 775 + "----------\n" 776 + "5. ERROR in X.java (at line 8)\n" 777 + " * @see #smr_foo(Hashtable a, Vector b, boolean c) Invalid reference: unresolved argument type\n" 778 + " ^^^^^^\n" 779 + "Javadoc: Vector cannot be resolved to a type\n" 780 + "----------\n", 781 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); 782 } 783 test045()784 public void test045() { 785 this.runConformTest( 786 new String[] { 787 "X.java", 788 "import java.util.Vector;\n" 789 + "public class X {\n" 790 + " /**\n" 791 + " * Valid local methods references\n" 792 + " * \n" 793 + " * @see X#smr_foo() Valid local method reference\n" 794 + " * @see X#smr_foo(boolean,int,byte,short,char,long,float,double) Valid local method reference\n" 795 + " * @see X#smr_foo(String x, java.lang.String y, int z) Valid local method reference \n" 796 + " * @see X#smr_foo(java.util.Hashtable a, Vector b, boolean c) Valid local method reference\n" 797 + " */ \n" 798 + " public int x;\n" 799 + "\n" 800 + " // Empty methods definition for reference\n" 801 + " public void smr_foo() {\n" 802 + " }\n" 803 + " public void smr_foo(boolean b, int i, byte y, short s, char c, long l, float f, double d) {\n" 804 + " }\n" 805 + " public void smr_foo(String str1, java.lang.String str2, int i) {\n" 806 + " }\n" 807 + " public void smr_foo(java.util.Hashtable h, java.util.Vector v, boolean b) {\n" 808 + " }\n" 809 + "}\n" }); 810 } 811 test046()812 public void test046() { 813 this.runConformTest( 814 new String[] { 815 "test/deep/qualified/name/p/X.java", 816 "package test.deep.qualified.name.p;\n" 817 + "import java.util.Vector;\n" 818 + "public class X {\n" 819 + " /**\n" 820 + " * Valid local methods references\n" 821 + " * \n" 822 + " * @see test.deep.qualified.name.p.X#smr_foo() Valid local method reference\n" 823 + " * @see test.deep.qualified.name.p.X#smr_foo(boolean,int,byte,short,char,long,float,double) Valid local method reference\n" 824 + " * @see test.deep.qualified.name.p.X#smr_foo(String x, java.lang.String y, int z) Valid local method reference \n" 825 + " * @see test.deep.qualified.name.p.X#smr_foo(java.util.Hashtable a, Vector b, boolean c) Valid local method reference\n" 826 + " */ \n" 827 + " public int x;\n" 828 + "\n" 829 + " // Empty methods definition for reference\n" 830 + " public void smr_foo() {\n" 831 + " }\n" 832 + " public void smr_foo(boolean b, int i, byte y, short s, char c, long l, float f, double d) {\n" 833 + " }\n" 834 + " public void smr_foo(String str1, java.lang.String str2, int i) {\n" 835 + " }\n" 836 + " public void smr_foo(java.util.Hashtable h, java.util.Vector v, boolean b) {\n" 837 + " }\n" 838 + "}\n" }); 839 } 840 test047()841 public void test047() { 842 runConformReferenceTest( 843 new String[] { 844 "test/X.java", 845 "package test;\n" 846 + "public class X {\n" 847 + " /**\n" 848 + " * Valid package class methods references\n" 849 + " * \n" 850 + " * @see Visibility#vm_public() Valid ref: visible method\n" 851 + " * @see Visibility.VcPublic#vm_public() Valid ref: visible method in visible inner class\n" 852 + " * @see test.Visibility#vm_public() Valid ref: visible method\n" 853 + " * @see test.Visibility.VcPublic#vm_public() Valid ref: visible method in visible inner class\n" 854 + " */ \n" 855 + " public int x;\n" 856 + "}\n" }); 857 } 858 test048()859 public void test048() { 860 this.runNegativeReferenceTest( 861 new String[] { 862 "test/X.java", 863 "package test;\n" 864 + "public class X {\n" 865 + " /**\n" 866 + " * Invalid package class methods references (non-existence)\n" 867 + " * \n" 868 + " * @see Visibility#unknown() Invalid ref: non-existent method\n" 869 + " * @see Visibility.VcPublic#unknown() Invalid ref: non existent method in visible inner class\n" 870 + " * @see Unknown#vm_public() Invalid ref: non-existent class\n" 871 + " * @see Visibility.Unknown#vm_public() Invalid ref: non existent inner class\n" 872 + " */ \n" 873 + " public int x;\n" 874 + "}\n" }, 875 "----------\n" 876 + "1. ERROR in test\\X.java (at line 6)\n" 877 + " * @see Visibility#unknown() Invalid ref: non-existent method\n" 878 + " ^^^^^^^\n" 879 + "Javadoc: The method unknown() is undefined for the type Visibility\n" 880 + "----------\n" 881 + "2. ERROR in test\\X.java (at line 7)\n" 882 + " * @see Visibility.VcPublic#unknown() Invalid ref: non existent method in visible inner class\n" 883 + " ^^^^^^^\n" 884 + "Javadoc: The method unknown() is undefined for the type Visibility.VcPublic\n" 885 + "----------\n" 886 + "3. ERROR in test\\X.java (at line 8)\n" 887 + " * @see Unknown#vm_public() Invalid ref: non-existent class\n" 888 + " ^^^^^^^\n" 889 + "Javadoc: Unknown cannot be resolved to a type\n" 890 + "----------\n" 891 + "4. ERROR in test\\X.java (at line 9)\n" 892 + " * @see Visibility.Unknown#vm_public() Invalid ref: non existent inner class\n" 893 + " ^^^^^^^^^^^^^^^^^^\n" 894 + "Javadoc: Visibility.Unknown cannot be resolved to a type\n" 895 + "----------\n"); 896 } 897 test049()898 public void test049() { 899 this.runNegativeReferenceTest( 900 new String[] { 901 "test/X.java", 902 "package test;\n" 903 + "public class X {\n" 904 + " /**\n" 905 + " * Invalid package class methods references (non-visible)\n" 906 + " * \n" 907 + " * @see Visibility#vm_private() Invalid ref: non-visible method\n" 908 + " * @see Visibility.VcPrivate#unknown() Invalid ref: non visible inner class (non existent method)\n" 909 + " * @see Visibility.VcPublic#vm_private() Invalid ref: non visible method in visible inner class\n" 910 + " */ \n" 911 + " public int x;\n" 912 + "}\n" }, 913 "----------\n" 914 + "1. ERROR in test\\X.java (at line 6)\n" 915 + " * @see Visibility#vm_private() Invalid ref: non-visible method\n" 916 + " ^^^^^^^^^^\n" 917 + "Javadoc: The method vm_private() from the type Visibility is not visible\n" 918 + "----------\n" 919 + "2. ERROR in test\\X.java (at line 7)\n" 920 + " * @see Visibility.VcPrivate#unknown() Invalid ref: non visible inner class (non existent method)\n" 921 + " ^^^^^^^^^^^^^^^^^^^^\n" 922 + "Javadoc: The type Visibility.VcPrivate is not visible\n" 923 + "----------\n" 924 + "3. ERROR in test\\X.java (at line 8)\n" 925 + " * @see Visibility.VcPublic#vm_private() Invalid ref: non visible method in visible inner class\n" 926 + " ^^^^^^^^^^\n" 927 + "Javadoc: The method vm_private() from the type Visibility.VcPublic is not visible\n" 928 + "----------\n"); 929 } 930 test050()931 public void test050() { 932 this.runNegativeReferenceTest( 933 new String[] { 934 "test/X.java", 935 "package test;\n" 936 + "public class X {\n" 937 + " /**\n" 938 + " * Invalid package class methods references (non-applicable)\n" 939 + " * \n" 940 + " * @see Visibility#vm_private(int) Invalid ref: non-applicable method\n" 941 + " * @see Visibility#vm_public(String) Invalid ref: non-applicable method\n" 942 + " * @see Visibility.VcPublic#vm_private(Integer, byte) Invalid ref: non applicable method in visible inner class\n" 943 + " * @see Visibility.VcPublic#vm_public(Double z, Boolean x) Invalid ref: non applicable method in visible inner class\n" 944 + " */ \n" 945 + " public int x;\n" 946 + "}\n" }, 947 "----------\n" 948 + "1. ERROR in test\\X.java (at line 6)\n" 949 + " * @see Visibility#vm_private(int) Invalid ref: non-applicable method\n" 950 + " ^^^^^^^^^^\n" 951 + "Javadoc: The method vm_private() in the type Visibility is not applicable for the arguments (int)\n" 952 + "----------\n" 953 + "2. ERROR in test\\X.java (at line 7)\n" 954 + " * @see Visibility#vm_public(String) Invalid ref: non-applicable method\n" 955 + " ^^^^^^^^^\n" 956 + "Javadoc: The method vm_public() in the type Visibility is not applicable for the arguments (String)\n" 957 + "----------\n" 958 + "3. ERROR in test\\X.java (at line 8)\n" 959 + " * @see Visibility.VcPublic#vm_private(Integer, byte) Invalid ref: non applicable method in visible inner class\n" 960 + " ^^^^^^^^^^\n" 961 + "Javadoc: The method vm_private() in the type Visibility.VcPublic is not applicable for the arguments (Integer, byte)\n" 962 + "----------\n" 963 + "4. ERROR in test\\X.java (at line 9)\n" 964 + " * @see Visibility.VcPublic#vm_public(Double z, Boolean x) Invalid ref: non applicable method in visible inner class\n" 965 + " ^^^^^^^^^\n" 966 + "Javadoc: The method vm_public() in the type Visibility.VcPublic is not applicable for the arguments (Double, Boolean)\n" 967 + "----------\n"); 968 } 969 test051()970 public void test051() { 971 this.runNegativeReferenceTest( 972 new String[] { 973 "test/X.java", 974 "package test;\n" 975 + "import test.copy.*;\n" 976 + "public class X {\n" 977 + " /**\n" 978 + " * Invalid other package non visible class methods references (non existent/visible arguments)\n" 979 + " * \n" 980 + " * @see VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" 981 + " * @see test.copy.VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" 982 + " */ \n" 983 + " public int x;\n" 984 + "}\n" }, 985 "----------\n" + 986 "1. WARNING in test\\X.java (at line 2)\n"+ 987 " import test.copy.*;\n"+ 988 " ^^^^^^^^^\n"+ 989 "The import test.copy is never used\n"+ 990 "----------\n"+ 991 "2. ERROR in test\\X.java (at line 7)\n" + 992 " * @see VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" + 993 " ^^^^^^^^^^^^^^^^^\n" + 994 "Javadoc: The type VisibilityPackage is not visible\n" + 995 "----------\n" + 996 "3. ERROR in test\\X.java (at line 8)\n" + 997 " * @see test.copy.VisibilityPackage#unknown() Invalid ref: non visible class (non existent method)\n" + 998 " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 999 "Javadoc: The type test.copy.VisibilityPackage is not visible\n" + 1000 "----------\n"); 1001 } 1002 test052()1003 public void test052() { 1004 runConformReferenceTest( 1005 new String[] { 1006 "test/X.java", 1007 "package test;\n" + 1008 "import test.copy.VisibilityPublic;\n" + 1009 "public class X {\n" + 1010 " /**\n" + 1011 " * Valid other package visible class methods references \n" + 1012 " * \n" + 1013 " * @see VisibilityPublic#vm_public() Valid ref to not visible method of other package class\n" + 1014 " * @see test.copy.VisibilityPublic.VpPublic#vm_public() Valid ref to visible method of other package public inner class\n" + 1015 " */\n" + 1016 " public int x;\n" + 1017 "}\n" 1018 } 1019 ); 1020 } 1021 test053()1022 public void test053() { 1023 runConformReferenceTest( 1024 new String[] { 1025 "test/X.java", 1026 "package test;\n" 1027 + "public class X {\n" 1028 + " /**\n" 1029 + " * Valid other package visible class methods references \n" 1030 + " * \n" 1031 + " * @see test.copy.VisibilityPublic#vm_public() Valid ref to not visible method of other package class\n" 1032 + " * @see test.copy.VisibilityPublic.VpPublic#vm_public() Valid ref to visible method of other package public inner class\n" 1033 + " */\n" 1034 + " public int x;\n" 1035 + "}\n" }); 1036 } 1037 1038 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=451418, [1.8][compiler] NPE at ParameterizedGenericMethodBinding.computeCompatibleMethod18 test451418()1039 public void test451418() { 1040 if (this.complianceLevel < ClassFileConstants.JDK1_5) 1041 return; 1042 1043 runNegativeTest( 1044 new String[] { 1045 "X.java", 1046 "class Repro {\n" + 1047 " public static <T> FieldSet<T> emptySet() { return null; }\n" + 1048 " /**\n" + 1049 " * {@link #emptySet} \n" + 1050 " */\n" + 1051 " public int i;\n" + 1052 "}\n" 1053 }, 1054 "----------\n" + 1055 "1. ERROR in X.java (at line 2)\n" + 1056 " public static <T> FieldSet<T> emptySet() { return null; }\n" + 1057 " ^^^^^^^^\n" + 1058 "FieldSet cannot be resolved to a type\n" + 1059 "----------\n"); 1060 } 1061 } 1062