|
Lines 57-66
Link Here
|
| 57 |
"@Target(ElementType.METHOD) @interface Annot{}\n" + |
57 |
"@Target(ElementType.METHOD) @interface Annot{}\n" + |
| 58 |
"public interface I {\n" + |
58 |
"public interface I {\n" + |
| 59 |
" default void foo1() {}\n" + |
59 |
" default void foo1() {}\n" + |
| 60 |
" public default synchronized void foo2() { System.exit(0); }\n" + |
60 |
" public default void foo2() { System.exit(0); }\n" + |
| 61 |
" strictfp default void foo3() {}\n" + |
61 |
" strictfp default void foo3() {}\n" + |
| 62 |
" public default strictfp synchronized void foo4() {}\n" + |
62 |
" public default strictfp void foo4() {}\n" + |
| 63 |
" public default strictfp synchronized @Annot void foo5() {}\n" + |
63 |
" public default strictfp @Annot void foo5() {}\n" + |
| 64 |
"}\n" + |
64 |
"}\n" + |
| 65 |
"public class Wrong{}\n"}, // TODO remove me |
65 |
"public class Wrong{}\n"}, // TODO remove me |
| 66 |
// TODO remove me: |
66 |
// TODO remove me: |
|
Lines 81-90
Link Here
|
| 81 |
"@Target(ElementType.METHOD) @interface Annot{}\n" + |
81 |
"@Target(ElementType.METHOD) @interface Annot{}\n" + |
| 82 |
"public interface I {\n" + |
82 |
"public interface I {\n" + |
| 83 |
" default void foo1() { System.out.println(3); }\n" + |
83 |
" default void foo1() { System.out.println(3); }\n" + |
| 84 |
" public default synchronized void foo2() {}\n" + |
84 |
" public default void foo2() {}\n" + |
| 85 |
" stritfp default void foo3() {}\n" + // typo in strictfp |
85 |
" stritfp default void foo3() {}\n" + // typo in strictfp |
| 86 |
" default public strictfp synchronized void foo4() {}\n" + |
86 |
" default public strictfp void foo4() {}\n" + |
| 87 |
" public strictfp default synchronized @Annot void foo5() {}\n" + |
87 |
" public strictfp default @Annot void foo5() {}\n" + |
| 88 |
" public default <T> T foo6(T t) { return t; }\n" + |
88 |
" public default <T> T foo6(T t) { return t; }\n" + |
| 89 |
"}\n"}, |
89 |
"}\n"}, |
| 90 |
"----------\n" + |
90 |
"----------\n" + |
|
Lines 169-190
Link Here
|
| 169 |
"3. ERROR in I.java (at line 4)\n" + |
169 |
"3. ERROR in I.java (at line 4)\n" + |
| 170 |
" native default void foo3() {}\n" + |
170 |
" native default void foo3() {}\n" + |
| 171 |
" ^^^^^^\n" + |
171 |
" ^^^^^^\n" + |
| 172 |
"Illegal modifier for the interface method foo3; only public, abstract, strictfp & synchronized are permitted\n" + |
172 |
"Illegal modifier for the interface method foo3; only public, abstract, strictfp, default & static are permitted\n" + |
| 173 |
"----------\n" + |
173 |
"----------\n" + |
| 174 |
"4. ERROR in I.java (at line 5)\n" + |
174 |
"4. ERROR in I.java (at line 5)\n" + |
| 175 |
" default native void foo4() {}\n" + |
175 |
" default native void foo4() {}\n" + |
| 176 |
" ^^^^^^\n" + |
176 |
" ^^^^^^\n" + |
| 177 |
"Illegal modifier for the interface method foo4; only public, abstract, strictfp & synchronized are permitted\n" + |
177 |
"Illegal modifier for the interface method foo4; only public, abstract, strictfp, default & static are permitted\n" + |
| 178 |
"----------\n" + |
178 |
"----------\n" + |
| 179 |
"5. ERROR in I.java (at line 6)\n" + |
179 |
"5. ERROR in I.java (at line 6)\n" + |
| 180 |
" static default void foo5() {}\n" + |
180 |
" static default void foo5() {}\n" + |
| 181 |
" ^^^^^^\n" + |
181 |
" ^^^^^^\n" + |
| 182 |
"Illegal modifier for the interface method foo5; only public, abstract, strictfp & synchronized are permitted\n" + |
182 |
"Illegal modifier for the interface method foo5; only public, abstract, strictfp, default & static are permitted\n" + |
| 183 |
"----------\n" + |
183 |
"----------\n" + |
| 184 |
"6. ERROR in I.java (at line 7)\n" + |
184 |
"6. ERROR in I.java (at line 7)\n" + |
| 185 |
" default static void foo6() {}\n" + |
185 |
" default static void foo6() {}\n" + |
| 186 |
" ^^^^^^\n" + |
186 |
" ^^^^^^\n" + |
| 187 |
"Illegal modifier for the interface method foo6; only public, abstract, strictfp & synchronized are permitted\n" + |
187 |
"Illegal modifier for the interface method foo6; only public, abstract, strictfp, default & static are permitted\n" + |
| 188 |
"----------\n"); |
188 |
"----------\n"); |
| 189 |
} |
189 |
} |
| 190 |
|
190 |
|
|
Lines 220-226
Link Here
|
| 220 |
"4. ERROR in I.java (at line 7)\n" + |
220 |
"4. ERROR in I.java (at line 7)\n" + |
| 221 |
" abstract static default void foo5() {}\n" + |
221 |
" abstract static default void foo5() {}\n" + |
| 222 |
" ^^^^^^\n" + |
222 |
" ^^^^^^\n" + |
| 223 |
"Illegal modifier for the interface method foo5; only public, abstract, strictfp & synchronized are permitted\n" + |
223 |
"Illegal modifier for the interface method foo5; only public, abstract, strictfp, default & static are permitted\n" + |
| 224 |
"----------\n" + |
224 |
"----------\n" + |
| 225 |
"5. ERROR in I.java (at line 7)\n" + |
225 |
"5. ERROR in I.java (at line 7)\n" + |
| 226 |
" abstract static default void foo5() {}\n" + |
226 |
" abstract static default void foo5() {}\n" + |
|
Lines 323-328
Link Here
|
| 323 |
options); |
323 |
options); |
| 324 |
} |
324 |
} |
| 325 |
|
325 |
|
|
|
326 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=400977 |
| 327 |
// test for error on synchronized |
| 328 |
public void testModifiers400977() { |
| 329 |
runNegativeTest( |
| 330 |
new String[] { |
| 331 |
"I.java", |
| 332 |
"import java.lang.annotation.*;\n" + |
| 333 |
"@Target(ElementType.METHOD) @interface Annot{}\n" + |
| 334 |
"public interface I {\n" + |
| 335 |
" synchronized default void foo() { System.out.println(3); }\n" + |
| 336 |
"}\n"}, |
| 337 |
"----------\n" + |
| 338 |
"1. ERROR in I.java (at line 4)\n" + |
| 339 |
" synchronized default void foo() { System.out.println(3); }\n" + |
| 340 |
" ^^^^^\n" + |
| 341 |
"Illegal modifier for the interface method foo; only public, abstract, strictfp, default & static are permitted\n" + |
| 342 |
"----------\n"); |
| 343 |
} |
| 344 |
|
| 326 |
// JLS 9.4.2 - default method cannot override method from Object |
345 |
// JLS 9.4.2 - default method cannot override method from Object |
| 327 |
// Bug 382355 - [1.8][compiler] Compiler accepts erroneous default method |
346 |
// Bug 382355 - [1.8][compiler] Compiler accepts erroneous default method |
| 328 |
// new error message |
347 |
// new error message |