1 /*******************************************************************************
2 * Copyright (c) 2000, 2019 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.parser;
15
16 import java.util.Hashtable;
17 import java.util.Map;
18
19 import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest;
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 ParserTest extends AbstractRegressionTest {
25 static {
26 // TESTS_NAMES = new String[] { "test000" };
27 // TESTS_NUMBERS = new int[] { 18 };
28 // TESTS_RANGE = new int[] { 11, -1 };
29 }
ParserTest(String name)30 public ParserTest(String name) {
31 super(name);
32 }
test001()33 public void test001() {
34 this.runNegativeTest(
35 new String[] {
36 "X.java",
37 "public class X {\n" +
38 " void foo(){\n" +
39 " throws\n" +
40 " }\n" +
41 "}\n"
42 },
43 "----------\n" +
44 "1. ERROR in X.java (at line 3)\n" +
45 " throws\n" +
46 " ^^^^^^\n" +
47 "Syntax error on token \"throws\", delete this token\n" +
48 "----------\n"
49 );
50 }
test002()51 public void test002() {
52 this.runNegativeTest(
53 new String[] {
54 "X.java",
55 "public class X {\n" +
56 " void foo(){\n" +
57 " throws new\n" +
58 " }\n" +
59 "}\n"
60 },
61 "----------\n" +
62 "1. ERROR in X.java (at line 3)\n" +
63 " throws new\n" +
64 " ^^^^^^^^^^\n" +
65 "Syntax error on tokens, delete these tokens\n" +
66 "----------\n"
67 );
68 }
test003()69 public void test003() {
70 this.runNegativeTest(
71 new String[] {
72 "X.java",
73 "public class X {\n" +
74 " void foo(){\n" +
75 " throws new X\n" +
76 " }\n" +
77 "}\n"
78 },
79 "----------\n" +
80 "1. ERROR in X.java (at line 3)\n" +
81 " throws new X\n" +
82 " ^^^^^^\n" +
83 "Syntax error on token \"throws\", throw expected\n" +
84 "----------\n" +
85 "2. ERROR in X.java (at line 3)\n" +
86 " throws new X\n" +
87 " ^\n" +
88 "Syntax error, insert \"( )\" to complete Expression\n" +
89 "----------\n" +
90 "3. ERROR in X.java (at line 3)\n" +
91 " throws new X\n" +
92 " ^\n" +
93 "Syntax error, insert \";\" to complete BlockStatements\n" +
94 "----------\n");
95 }
test004()96 public void test004() {
97 this.runNegativeTest(
98 new String[] {
99 "X.java",
100 "public class X {\n" +
101 " {\n" +
102 " throws\n" +
103 " }\n" +
104 "}\n"
105 },
106 "----------\n" +
107 "1. ERROR in X.java (at line 3)\n" +
108 " throws\n" +
109 " ^^^^^^\n" +
110 "Syntax error on token \"throws\", delete this token\n" +
111 "----------\n"
112 );
113 }
test005()114 public void test005() {
115 this.runNegativeTest(
116 new String[] {
117 "X.java",
118 "public class X {\n" +
119 " {\n" +
120 " throws new\n" +
121 " }\n" +
122 "}\n"
123 },
124 "----------\n" +
125 "1. ERROR in X.java (at line 3)\n" +
126 " throws new\n" +
127 " ^^^^^^^^^^\n" +
128 "Syntax error on tokens, delete these tokens\n" +
129 "----------\n"
130 );
131 }
test006()132 public void test006() {
133 this.runNegativeTest(
134 new String[] {
135 "X.java",
136 "public class X {\n" +
137 " {\n" +
138 " throws new X\n" +
139 " }\n" +
140 "}\n"
141 },
142 "----------\n" +
143 "1. ERROR in X.java (at line 3)\n" +
144 " throws new X\n" +
145 " ^^^^^^\n" +
146 "Syntax error on token \"throws\", throw expected\n" +
147 "----------\n" +
148 "2. ERROR in X.java (at line 3)\n" +
149 " throws new X\n" +
150 " ^\n" +
151 "Syntax error, insert \"( )\" to complete Expression\n" +
152 "----------\n" +
153 "3. ERROR in X.java (at line 3)\n" +
154 " throws new X\n" +
155 " ^\n" +
156 "Syntax error, insert \";\" to complete BlockStatements\n" +
157 "----------\n");
158 }
test007()159 public void test007() {
160 this.runNegativeTest(
161 new String[] {
162 "X.java",
163 "public class X {\n" +
164 " void foo()throw {\n" +
165 " }\n" +
166 "}\n"
167 },
168 "----------\n" +
169 "1. ERROR in X.java (at line 1)\n" +
170 " public class X {\n" +
171 " ^\n" +
172 "Syntax error, insert \"}\" to complete ClassBody\n" +
173 "----------\n" +
174 "2. ERROR in X.java (at line 2)\n" +
175 " void foo()throw {\n" +
176 " ^^^^^\n" +
177 "Syntax error on token \"throw\", { expected\n" +
178 "----------\n"
179 );
180 }
test008()181 public void test008() {
182 this.runNegativeTest(
183 new String[] {
184 "X.java",
185 "public class X {\n" +
186 " void foo()throw E {\n" +
187 " }\n" +
188 "}\n"
189 },
190 "----------\n" +
191 "1. ERROR in X.java (at line 1)\n" +
192 " public class X {\n" +
193 " ^\n" +
194 "Syntax error, insert \"}\" to complete ClassBody\n" +
195 "----------\n" +
196 "2. ERROR in X.java (at line 2)\n" +
197 " void foo()throw E {\n" +
198 " ^^^^^\n" +
199 "Syntax error on token \"throw\", throws expected\n" +
200 "----------\n" +
201 "3. ERROR in X.java (at line 4)\n" +
202 " }\n" +
203 " ^\n" +
204 "Syntax error on token \"}\", delete this token\n" +
205 "----------\n"
206 );
207 }
test009()208 public void test009() {
209 this.runNegativeTest(
210 new String[] {
211 "X.java",
212 "public class X {\n" +
213 " void foo(){\n" +
214 " throws e\n" +
215 " }\n" +
216 "}\n"
217 },
218 "----------\n" +
219 "1. ERROR in X.java (at line 3)\n" +
220 " throws e\n" +
221 " ^^^^^^^^\n" +
222 "Syntax error on tokens, delete these tokens\n" +
223 "----------\n"
224 );
225 }
test010()226 public void test010() {
227 this.runNegativeTest(
228 new String[] {
229 "X.java",
230 "public class X {\n" +
231 " void foo(){\n" +
232 " throws e;\n" +
233 " }\n" +
234 "}\n"
235 },
236 "----------\n" +
237 "1. ERROR in X.java (at line 3)\n" +
238 " throws e;\n" +
239 " ^^^^^^\n" +
240 "Syntax error on token \"throws\", throw expected\n" +
241 "----------\n"
242 );
243 }
_test011()244 public void _test011() {
245 this.runNegativeTest(
246 new String[] {
247 "X.java",
248 "public class X {\n" +
249 " public void foo(X, Object o, String s) {\n" +
250 " }\n" +
251 " public void bar(){}\n" +
252 "}\n"
253 },
254 "----------\n" +
255 "1. ERROR in X.java (at line 2)\n" +
256 " public void foo(X, Object o, String s) {\n" +
257 " ^\n" +
258 "Syntax error on token \",\", . expected\n" +
259 "----------\n"
260 );
261 }
262 /*
263 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=40681
264 */
test012()265 public void test012() {
266 Hashtable nls = new Hashtable();
267 nls.put(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, CompilerOptions.ERROR);
268 runNegativeTest(
269 true,
270 new String[] {
271 "X.java",
272 "public class X {\n" +
273 " public void foo() {\n" +
274 " \"foo\".equals(\"bar\");\n" +
275 " ;\n" +
276 " }\n" +
277 "}\n"
278 },
279 null, nls,
280 "----------\n" +
281 "1. ERROR in X.java (at line 3)\n" +
282 " \"foo\".equals(\"bar\");\n" +
283 " ^^^^^\n" +
284 "Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" +
285 "----------\n" +
286 "2. ERROR in X.java (at line 3)\n" +
287 " \"foo\".equals(\"bar\");\n" +
288 " ^^^^^\n" +
289 "Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" +
290 "----------\n",
291 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
292 }
293 /*
294 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=40681
295 */
test013()296 public void test013() {
297 Hashtable nls = new Hashtable();
298 nls.put(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, CompilerOptions.ERROR);
299 runNegativeTest(
300 true,
301 new String[] {
302 "X.java",
303 "public class X {\n" +
304 " public void foo() {\n" +
305 " \"foo\".equals(\"bar\");\n" +
306 " //;\n" +
307 " }\n" +
308 "}\n"
309 },
310 null, nls,
311 "----------\n" +
312 "1. ERROR in X.java (at line 3)\n" +
313 " \"foo\".equals(\"bar\");\n" +
314 " ^^^^^\n" +
315 "Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" +
316 "----------\n" +
317 "2. ERROR in X.java (at line 3)\n" +
318 " \"foo\".equals(\"bar\");\n" +
319 " ^^^^^\n" +
320 "Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" +
321 "----------\n",
322 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
323 }
324 /*
325 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=47227
326 */
test014()327 public void test014() {
328 this.runNegativeTest(
329 new String[] {
330 "X.java",
331 "public class X {\n" +
332 " public void foo() { \n" +
333 " import java.lang.*;\n" +
334 " } \n" +
335 "}\n"
336 },
337 "----------\n" +
338 "1. ERROR in X.java (at line 3)\n" +
339 " import java.lang.*;\n" +
340 " ^^^^^^\n" +
341 "Syntax error on token \"import\", delete this token\n" +
342 "----------\n" +
343 "2. ERROR in X.java (at line 3)\n" +
344 " import java.lang.*;\n" +
345 " ^^^^^^^^^^^^^^^^^\n" +
346 "Syntax error on token(s), misplaced construct(s)\n" +
347 "----------\n"
348 );
349 }
350 /*
351 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=60848
352 */
test015()353 public void test015() {
354 this.runNegativeTest(
355 new String[] {
356 "X.java",
357 "public class X {\n" +
358 "// some code\n" +
359 "}\n" +
360 "/*\n" +
361 "// some comments\n"
362 },
363 "----------\n" +
364 "1. ERROR in X.java (at line 4)\n" +
365 " /*\n" +
366 "// some comments\n" +
367 "\n" +
368 " ^^^^^^^^^^^^^^^^^^^^\n" +
369 "Unexpected end of comment\n" +
370 "----------\n"
371 );
372 }
373 /*
374 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=60848
375 */
test016()376 public void test016() {
377 this.runNegativeTest(
378 new String[] {
379 "X.java",
380 "public class X {\n" +
381 " String s = \""
382 },
383 "----------\n" +
384 "1. ERROR in X.java (at line 2)\n" +
385 " String s = \"\n" +
386 " ^\n" +
387 "String literal is not properly closed by a double-quote\n" +
388 "----------\n"
389 );
390 }
391 /*
392 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=60848
393 */
test017()394 public void test017() {
395 this.runNegativeTest(
396 new String[] {
397 "X.java",
398 "public class X {\n" +
399 " char c = '"
400 },
401 "----------\n" +
402 "1. ERROR in X.java (at line 2)\n" +
403 " char c = \'\n" +
404 " ^\n" +
405 "Invalid character constant\n" +
406 "----------\n"
407 );
408 }
409 /*
410 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=60848
411 */
test018()412 public void test018() {
413 this.runNegativeTest(
414 new String[] {
415 "X.java",
416 "public class X {\n" +
417 " char c = '\\u0"
418 },
419 "----------\n" +
420 "1. ERROR in X.java (at line 2)\n" +
421 " char c = \'\\u0\n" +
422 " ^^^\n" +
423 "Invalid unicode\n" +
424 "----------\n"
425 );
426 }
427 /*
428 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=12287
429 */
test019()430 public void test019() {
431 this.runNegativeTest(
432 new String[] {
433 "X.java",
434 "public class X {\n" +
435 " public void doit() {\n" +
436 " int[] foo = null;\n" +
437 " foo[0] = \n" +
438 " }\n" +
439 "}"
440 },
441 "----------\n" +
442 "1. ERROR in X.java (at line 4)\n" +
443 " foo[0] = \n" +
444 " ^\n" +
445 "Syntax error, insert \"AssignmentOperator Expression\" to complete Assignment\n" +
446 "----------\n" +
447 "2. ERROR in X.java (at line 4)\n" +
448 " foo[0] = \n" +
449 " ^\n" +
450 "Syntax error, insert \";\" to complete Statement\n" +
451 "----------\n"
452 );
453 }
454 /*
455 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=38895
456 */
test020()457 public void test020() {
458 this.runNegativeTest(
459 new String[] {
460 "X.java",
461 "public class X {\n" +
462 " public static void main(String[] args) {\n" +
463 " }\n" +
464 " public static int newLibraryEntry() {\n" +
465
466 " if (sourceAttachmentPath != null) {\n" +
467 " if (sourceAttachmentPath.isEmpty()) { && !\n" +
468 "sourceAttachmentPath.isAbsolute()) {\n" +
469 " foo();\n" +
470 " }\n" +
471 " return null;\n" +
472 " }\n" +
473 " }\n" +
474 " public void foo() {\n" +
475 " }\n" +
476 " public void bar() {\n" +
477 " }\n" +
478 "}"
479 },
480 "----------\n" +
481 "1. ERROR in X.java (at line 6)\n" +
482 " if (sourceAttachmentPath.isEmpty()) { && !\n" +
483 " ^^\n" +
484 "Syntax error on token \"&&\", invalid (\n" +
485 "----------\n" +
486 "2. ERROR in X.java (at line 7)\n" +
487 " sourceAttachmentPath.isAbsolute()) {\n" +
488 " ^\n" +
489 "Syntax error on token \"{\", invalid AssignmentOperator\n" +
490 "----------\n"
491 );
492 }
test021()493 public void test021() {
494 StringBuffer buffer = new StringBuffer();
495 buffer.append("public class X {\n");
496 for (int i = 0; i < 1000; i++) {
497 buffer.append("\tint field_" + i + " = 0; \n");
498 }
499 for (int i = 0; i < 1000; i++) {
500 if (i == 0)
501 buffer.append("\tvoid method_" + i + "() { /* default */ } \n");
502 else
503 buffer.append("\tvoid method_" + i + "() { method_" + (i - 1) + "() \n");
504 }
505 buffer.append("}\n");
506
507 Hashtable options = new Hashtable();
508 options.put(CompilerOptions.OPTION_MaxProblemPerUnit, "10");
509 this.runNegativeTest(
510 new String[] {
511 "X.java",
512 buffer.toString()
513 },
514 "----------\n" +
515 "1. ERROR in X.java (at line 1003)\n" +
516 " void method_1() { method_0() \n" +
517 " ^\n" +
518 "Syntax error, insert \"}\" to complete MethodBody\n" +
519 "----------\n" +
520 "2. ERROR in X.java (at line 1003)\n" +
521 " void method_1() { method_0() \n" +
522 " ^\n" +
523 "Syntax error, insert \";\" to complete BlockStatements\n" +
524 "----------\n" +
525 "3. ERROR in X.java (at line 1004)\n" +
526 " void method_2() { method_1() \n" +
527 " ^\n" +
528 "Syntax error, insert \"}\" to complete MethodBody\n" +
529 "----------\n" +
530 "4. ERROR in X.java (at line 1004)\n" +
531 " void method_2() { method_1() \n" +
532 " ^\n" +
533 "Syntax error, insert \";\" to complete BlockStatements\n" +
534 "----------\n" +
535 "5. ERROR in X.java (at line 1005)\n" +
536 " void method_3() { method_2() \n" +
537 " ^\n" +
538 "Syntax error, insert \"}\" to complete MethodBody\n" +
539 "----------\n" +
540 "6. ERROR in X.java (at line 1005)\n" +
541 " void method_3() { method_2() \n" +
542 " ^\n" +
543 "Syntax error, insert \";\" to complete BlockStatements\n" +
544 "----------\n" +
545 "7. ERROR in X.java (at line 1006)\n" +
546 " void method_4() { method_3() \n" +
547 " ^\n" +
548 "Syntax error, insert \"}\" to complete MethodBody\n" +
549 "----------\n" +
550 "8. ERROR in X.java (at line 1006)\n" +
551 " void method_4() { method_3() \n" +
552 " ^\n" +
553 "Syntax error, insert \";\" to complete BlockStatements\n" +
554 "----------\n" +
555 "9. ERROR in X.java (at line 1007)\n" +
556 " void method_5() { method_4() \n" +
557 " ^\n" +
558 "Syntax error, insert \"}\" to complete MethodBody\n" +
559 "----------\n" +
560 "10. ERROR in X.java (at line 2002)\n" +
561 " }\n" +
562 " ^\n" +
563 "Syntax error, insert \"}\" to complete ClassBody\n" +
564 "----------\n",
565 null, // custom classpath
566 true, // flush previous output dir content
567 options // custom options
568 );
569 }
570 /*
571 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=156119
572 */
test022()573 public void test022() {
574 Map options = getCompilerOptions();
575 options.put(CompilerOptions.OPTION_ReportEmptyStatement, CompilerOptions.ERROR);
576 runNegativeTest(
577 true,
578 new String[] {
579 "X.java",
580 "interface X {\n" +
581 " int f= 1;;\n" +
582 "}"
583 },
584 null, options,
585 "----------\n" +
586 "1. ERROR in X.java (at line 2)\n" +
587 " int f= 1;;\n" +
588 " ^\n" +
589 "Unnecessary semicolon\n" +
590 "----------\n",
591 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
592 }
593 /*
594 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=156119
595 */
test023()596 public void test023() {
597 Map options = getCompilerOptions();
598 options.put(CompilerOptions.OPTION_ReportEmptyStatement, CompilerOptions.ERROR);
599 runNegativeTest(
600 true,
601 new String[] {
602 "X.java",
603 "class X {\n" +
604 " int f= 1;;\n" +
605 "}"
606 },
607 null, options,
608 "----------\n" +
609 "1. ERROR in X.java (at line 2)\n" +
610 " int f= 1;;\n" +
611 " ^\n" +
612 "Unnecessary semicolon\n" +
613 "----------\n",
614 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
615 }
616 /*
617 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=156119
618 */
test024()619 public void test024() {
620 Map options = getCompilerOptions();
621 options.put(CompilerOptions.OPTION_ReportEmptyStatement, CompilerOptions.ERROR);
622 runNegativeTest(
623 true,
624 new String[] {
625 "X.java",
626 "interface X {\n" +
627 " int f= 1;\\u003B\n" +
628 "}"
629 },
630 null, options,
631 "----------\n" +
632 "1. ERROR in X.java (at line 2)\n" +
633 " int f= 1;\\u003B\n" +
634 " ^^^^^^\n" +
635 "Unnecessary semicolon\n" +
636 "----------\n",
637 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
638 }
639 /*
640 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=160337
641 */
test025()642 public void test025() {
643 Map options = getCompilerOptions();
644 options.put(CompilerOptions.OPTION_ReportUndocumentedEmptyBlock, CompilerOptions.ERROR);
645 runNegativeTest(
646 true,
647 new String[] {
648 "X.java",
649 "public class X {\n" +
650 " static class Y {\n" +
651 " public void foo(int i) {}\n" +
652 " }\n" +
653 " static Y FakeInvocationSite = new Y(){\n" +
654 " public void foo(int i) {}\n" +
655 " };\n" +
656 "}"
657 },
658 null, options,
659 "----------\n" +
660 "1. ERROR in X.java (at line 3)\n" +
661 " public void foo(int i) {}\n" +
662 " ^^\n" +
663 "Empty block should be documented\n" +
664 "----------\n" +
665 "2. ERROR in X.java (at line 6)\n" +
666 " public void foo(int i) {}\n" +
667 " ^^\n" +
668 "Empty block should be documented\n" +
669 "----------\n",
670 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
671 }
672 /*
673 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=160337
674 */
test026()675 public void test026() {
676 Map options = getCompilerOptions();
677 options.put(CompilerOptions.OPTION_ReportUndocumentedEmptyBlock, CompilerOptions.ERROR);
678 runNegativeTest(
679 true,
680 new String[] {
681 "X.java",
682 "public class X {\n" +
683 " static class Y {\n" +
684 " public void foo(int i) {}\n" +
685 " }\n" +
686 " static Y FakeInvocationSite = new Y(){\n" +
687 " public void foo(int i) {\n" +
688 " class A {\n" +
689 " A() {}\n" +
690 " public void bar() {}\n" +
691 " }\n" +
692 " new A().bar();\n" +
693 " }\n" +
694 " };\n" +
695 "}"
696 },
697 null, options,
698 "----------\n" +
699 "1. ERROR in X.java (at line 3)\n" +
700 " public void foo(int i) {}\n" +
701 " ^^\n" +
702 "Empty block should be documented\n" +
703 "----------\n" +
704 "2. ERROR in X.java (at line 9)\n" +
705 " public void bar() {}\n" +
706 " ^^\n" +
707 "Empty block should be documented\n" +
708 "----------\n",
709 JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
710 }
711
712 /*
713 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=173992
714 */
test027()715 public void test027() {
716 this.runNegativeTest(
717 new String[] {
718 "X.java",
719 "import java.io.EOFException;\n" +
720 "import java.io.FileNotFoundException;\n" +
721 "import java.io.IOException;\n" +
722 "import org.xml.sax.SAXException;\n" +
723 "public class X {\n" +
724 "public void doSomething() throws FileNotFoundException, EOFException, SAXException{\n" +
725 "\n" +
726 "}\n" +
727 "public void doSomethingElse() {\n" +
728 "try {\n" +
729 " doSomething();\n" +
730 "}\n" +
731 " catch ( SAXException exception) {\n" +
732 "\n" +
733 "} \n" +
734 "catch ( FileNotFoundException exception ) {\n" +
735 "\n" +
736 "} \n" +
737 "catch (\n" +
738 " // working before the slashes\n" +
739 ") {\n" +
740 "\n" +
741 "} \n" +
742 "} \n" +
743 "}\n"
744 },
745 "----------\n" +
746 "1. ERROR in X.java (at line 19)\n" +
747 " catch (\n" +
748 " ^\n" +
749 "Syntax error on token \"(\", FormalParameter expected after this token\n" +
750 "----------\n"
751 );
752 }
753 /*
754 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=239198
755 */
_test028()756 public void _test028() {
757 String error = (this.complianceLevel == ClassFileConstants.JDK14) ?
758 "----------\n" +
759 "1. ERROR in X.java (at line 4)\n" +
760 " Srtring bar = \"\"\"\n" +
761 " }\n" +
762 " ^^^^\n" +
763 "Text block is not properly closed with the delimiter\n" +
764 "----------\n" :
765 "----------\n" +
766 "1. ERROR in X.java (at line 4)\n" +
767 " Srtring bar = \"\"\"\n" +
768 " ^^\n" +
769 "Non-externalized string literal; it should be followed by //$NON-NLS-<n>$\n" +
770 "----------\n" +
771 "2. ERROR in X.java (at line 4)\n" +
772 " Srtring bar = \"\"\"\n" +
773 " ^\n" +
774 "String literal is not properly closed by a double-quote\n" +
775 "----------\n";
776 Map options = getCompilerOptions();
777 options.put(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, CompilerOptions.ERROR);
778 runNegativeTest(
779 new String[] {
780 "X.java",
781 "class X {\n" +
782 " public static void foo(String param) {\n" +
783 " String foo= param;\n" +
784 " Srtring bar = \"\"\"\n" +
785 " }\n" +
786 "}"
787 },
788 error,
789 null,
790 true,
791 options);
792 }
testBug485477()793 public void testBug485477() {
794 runNegativeTest(
795 new String[] {
796 "T.java",
797 "public class T {{\n" +
798 " Object o = T.super; // error: '.' expected\n" + // instance initializer
799 " System.out.println(o.toString());\n" +
800 "}}\n" +
801 "class U {\n" +
802 " Object o1;\n" +
803 " Object o2 = T.super;\n" + // field initializer
804 " U() {\n" +
805 " o1 = U.super;\n" + // constructor
806 " System.out.println(o1.toString());\n" +
807 " }\n" +
808 "}"
809 },
810 "----------\n" +
811 "1. ERROR in T.java (at line 2)\n" +
812 " Object o = T.super; // error: \'.\' expected\n" +
813 " ^^^^^\n" +
814 "Syntax error, insert \". Identifier\" to complete Expression\n" +
815 "----------\n" +
816 "2. ERROR in T.java (at line 7)\n" +
817 " Object o2 = T.super;\n" +
818 " ^^^^^\n" +
819 "Syntax error, insert \". Identifier\" to complete Expression\n" +
820 "----------\n" +
821 "3. ERROR in T.java (at line 9)\n" +
822 " o1 = U.super;\n" +
823 " ^^^^^\n" +
824 "Syntax error, insert \". Identifier\" to complete Expression\n" +
825 "----------\n");
826 }
827 }
828