Lines 2437-2442
Link Here
|
2437 |
} |
2437 |
} |
2438 |
// check @Override annotation - strictly for superclasses (overrides) and not interfaces (implements) |
2438 |
// check @Override annotation - strictly for superclasses (overrides) and not interfaces (implements) |
2439 |
public void test077() { |
2439 |
public void test077() { |
|
|
2440 |
String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 |
2441 |
? "----------\n" + |
2442 |
"1. ERROR in X.java (at line 14)\n" + |
2443 |
" void foo() {}\n" + |
2444 |
" ^^^^^\n" + |
2445 |
"The method foo() of type X must override a superclass method\n" + |
2446 |
"----------\n" + |
2447 |
"2. ERROR in X.java (at line 18)\n" + |
2448 |
" public void baz() {}\n" + |
2449 |
" ^^^^^\n" + |
2450 |
"The method baz() of type X must override a superclass method\n" + |
2451 |
"----------\n" |
2452 |
: "----------\n" + |
2453 |
"1. ERROR in X.java (at line 14)\n" + |
2454 |
" void foo() {}\n" + |
2455 |
" ^^^^^\n" + |
2456 |
"The method foo() of type X must override a superclass method\n" + |
2457 |
"----------\n"; |
2440 |
this.runNegativeTest( |
2458 |
this.runNegativeTest( |
2441 |
new String[] { |
2459 |
new String[] { |
2442 |
"X.java", |
2460 |
"X.java", |
Lines 2460-2476
Link Here
|
2460 |
" public void baz() {}\n" + |
2478 |
" public void baz() {}\n" + |
2461 |
"}\n" |
2479 |
"}\n" |
2462 |
}, |
2480 |
}, |
2463 |
"----------\n" + |
2481 |
expectedOutput); |
2464 |
"1. ERROR in X.java (at line 14)\n" + |
|
|
2465 |
" void foo() {}\n" + |
2466 |
" ^^^^^\n" + |
2467 |
"The method foo() of type X must override a superclass method\n" + |
2468 |
"----------\n" + |
2469 |
"2. ERROR in X.java (at line 18)\n" + |
2470 |
" public void baz() {}\n" + |
2471 |
" ^^^^^\n" + |
2472 |
"The method baz() of type X must override a superclass method\n" + |
2473 |
"----------\n"); |
2474 |
} |
2482 |
} |
2475 |
|
2483 |
|
2476 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=80114 |
2484 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=80114 |
Lines 5611-5617
Link Here
|
5611 |
} |
5619 |
} |
5612 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=94759 |
5620 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=94759 |
5613 |
public void test168() { |
5621 |
public void test168() { |
5614 |
this.runNegativeTest( |
5622 |
String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 |
|
|
5623 |
? "----------\n" + |
5624 |
"1. ERROR in X.java (at line 2)\n" + |
5625 |
" @Override I clone();\n" + |
5626 |
" ^^^^^^^\n" + |
5627 |
"The method clone() of type I must override a superclass method\n" + |
5628 |
"----------\n" + |
5629 |
"2. ERROR in X.java (at line 7)\n" + |
5630 |
" @Override void foo();\n" + |
5631 |
" ^^^^^\n" + |
5632 |
"The method foo() of type J must override a superclass method\n" + |
5633 |
"----------\n" |
5634 |
: "----------\n" + |
5635 |
"1. ERROR in X.java (at line 2)\n" + |
5636 |
" @Override I clone();\n" + |
5637 |
" ^^^^^^^\n" + |
5638 |
"The method clone() of type I must override a superclass method\n" + |
5639 |
"----------\n"; |
5640 |
this.runNegativeTest( |
5615 |
new String[] { |
5641 |
new String[] { |
5616 |
"X.java", |
5642 |
"X.java", |
5617 |
"interface I {\n" + |
5643 |
"interface I {\n" + |
Lines 5623-5639
Link Here
|
5623 |
" @Override void foo();\n" + |
5649 |
" @Override void foo();\n" + |
5624 |
"}\n", |
5650 |
"}\n", |
5625 |
}, |
5651 |
}, |
5626 |
"----------\n" + |
5652 |
expectedOutput); |
5627 |
"1. ERROR in X.java (at line 2)\n" + |
|
|
5628 |
" @Override I clone();\n" + |
5629 |
" ^^^^^^^\n" + |
5630 |
"The method clone() of type I must override a superclass method\n" + |
5631 |
"----------\n" + |
5632 |
"2. ERROR in X.java (at line 7)\n" + |
5633 |
" @Override void foo();\n" + |
5634 |
" ^^^^^\n" + |
5635 |
"The method foo() of type J must override a superclass method\n" + |
5636 |
"----------\n"); |
5637 |
} |
5653 |
} |
5638 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97220 |
5654 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97220 |
5639 |
public void test169() { |
5655 |
public void test169() { |
Lines 7005-7008
Link Here
|
7005 |
"The array creation is unnecessary in an annotation value; only an array initializer is allowed\n" + |
7021 |
"The array creation is unnecessary in an annotation value; only an array initializer is allowed\n" + |
7006 |
"----------\n"); |
7022 |
"----------\n"); |
7007 |
} |
7023 |
} |
|
|
7024 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141931 |
7025 |
public void test214() { |
7026 |
String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6 |
7027 |
? "----------\n" + |
7028 |
"1. ERROR in X.java (at line 3)\n" + |
7029 |
" void foo();\n" + |
7030 |
" ^^^^^\n" + |
7031 |
"The method foo() of type I must override a superclass method\n" + |
7032 |
"----------\n" + |
7033 |
"2. ERROR in X.java (at line 8)\n" + |
7034 |
" public void foo() {}\n" + |
7035 |
" ^^^^^\n" + |
7036 |
"The method foo() of type X must override a superclass method\n" + |
7037 |
"----------\n" + |
7038 |
"3. ERROR in X.java (at line 13)\n" + |
7039 |
" void foo();\n" + |
7040 |
" ^^^^^\n" + |
7041 |
"The method foo() of type J must override a superclass method\n" + |
7042 |
"----------\n" |
7043 |
: "----------\n" + |
7044 |
"1. ERROR in X.java (at line 3)\n" + |
7045 |
" void foo();\n" + |
7046 |
" ^^^^^\n" + |
7047 |
"The method foo() of type I must override a superclass method\n" + |
7048 |
"----------\n"; |
7049 |
this.runNegativeTest( |
7050 |
new String[] { |
7051 |
"X.java", |
7052 |
"interface I {\n" + |
7053 |
" @Override\n" + |
7054 |
" void foo();\n" + |
7055 |
" void bar();\n" + |
7056 |
"}\n" + |
7057 |
"public class X implements I {\n" + |
7058 |
" @Override\n" + |
7059 |
" public void foo() {}\n" + |
7060 |
" public void bar() {}\n" + |
7061 |
"}\n" + |
7062 |
"interface J extends I {\n" + |
7063 |
" @Override\n" + |
7064 |
" void foo();\n" + |
7065 |
"}\n", |
7066 |
}, |
7067 |
expectedOutput); |
7068 |
} |
7069 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=141931 |
7070 |
// variant |
7071 |
public void test215() { |
7072 |
String sources[] = new String[] { |
7073 |
"I.java", |
7074 |
"public interface I {\n" + |
7075 |
" void foo();\n" + |
7076 |
"}\n", |
7077 |
"X.java", |
7078 |
"abstract class X implements I {\n" + |
7079 |
"}\n", |
7080 |
"Y.java", |
7081 |
"class Y extends X {\n" + |
7082 |
" @Override\n" + |
7083 |
" public void foo() {}\n" + |
7084 |
"}\n"}; |
7085 |
if (new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_6) { |
7086 |
this.runNegativeTest(sources, |
7087 |
"----------\n" + |
7088 |
"1. ERROR in Y.java (at line 3)\r\n" + |
7089 |
" public void foo() {}\r\n" + |
7090 |
" ^^^^^\n" + |
7091 |
"The method foo() of type Y must override a superclass method\n" + |
7092 |
"----------\n"); |
7093 |
} else { |
7094 |
this.runConformTest(sources, |
7095 |
""); |
7096 |
} |
7097 |
} |
7008 |
} |
7098 |
} |