Lines 8869-8872
Link Here
|
8869 |
"Cycle detected: the annotation type Test<T>.Anno cannot contain attributes of the annotation type itself\n" + |
8869 |
"Cycle detected: the annotation type Test<T>.Anno cannot contain attributes of the annotation type itself\n" + |
8870 |
"----------\n"); |
8870 |
"----------\n"); |
8871 |
} |
8871 |
} |
|
|
8872 |
|
8873 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=163194 |
8874 |
// To check Missing override annotation error when a method implements |
8875 |
// and also overrides a method in a superclass |
8876 |
public void test271a() { |
8877 |
String testString [] = new String[] { |
8878 |
"T.java", |
8879 |
"public interface T {\n" + |
8880 |
" void m();\n" + |
8881 |
"}\n" + |
8882 |
"abstract class A implements T {\n" + |
8883 |
"}\n" + |
8884 |
"class B extends A {\n" + |
8885 |
" public void m() {}\n" + |
8886 |
"}\n" |
8887 |
}; |
8888 |
Map customOptions = getCompilerOptions(); |
8889 |
customOptions.put( |
8890 |
CompilerOptions.OPTION_ReportMissingOverrideAnnotation, |
8891 |
CompilerOptions.ERROR); |
8892 |
customOptions.put( |
8893 |
CompilerOptions.OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation, |
8894 |
CompilerOptions.ENABLED); |
8895 |
if (new CompilerOptions(customOptions).sourceLevel >= ClassFileConstants.JDK1_6) { |
8896 |
String expectedOutput = |
8897 |
"----------\n" + |
8898 |
"1. ERROR in T.java (at line 7)\n" + |
8899 |
" public void m() {}\n" + |
8900 |
" ^^^\n" + |
8901 |
"The method m() of type B should be tagged with @Override since it actually overrides a supertype method\n" + |
8902 |
"----------\n"; |
8903 |
this.runNegativeTest( |
8904 |
true, |
8905 |
testString, |
8906 |
null, customOptions, |
8907 |
expectedOutput, |
8908 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8909 |
} else { |
8910 |
this.runConformTest( |
8911 |
true, testString, |
8912 |
null, |
8913 |
customOptions, |
8914 |
null, |
8915 |
null, null, |
8916 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8917 |
} |
8918 |
} |
8919 |
|
8920 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=163194 |
8921 |
// To check Missing override annotation error when a method implements but |
8922 |
// doesn't overrides |
8923 |
public void test271b() { |
8924 |
String testString [] = new String[] { |
8925 |
"Over.java", |
8926 |
"interface I {\n" + |
8927 |
" void m();\n" + |
8928 |
"}\n" + |
8929 |
"public class Over implements I {\n" + |
8930 |
" public void m() {}\n" + |
8931 |
"}\n" |
8932 |
}; |
8933 |
Map customOptions = getCompilerOptions(); |
8934 |
customOptions.put( |
8935 |
CompilerOptions.OPTION_ReportMissingOverrideAnnotation, |
8936 |
CompilerOptions.ERROR); |
8937 |
customOptions.put( |
8938 |
CompilerOptions.OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation, |
8939 |
CompilerOptions.ENABLED); |
8940 |
if (new CompilerOptions(customOptions).sourceLevel >= ClassFileConstants.JDK1_6) { |
8941 |
String expectedOutput = |
8942 |
"----------\n" + |
8943 |
"1. ERROR in Over.java (at line 5)\n" + |
8944 |
" public void m() {}\n" + |
8945 |
" ^^^\n" + |
8946 |
"The method m() of type Over should be tagged with @Override since it actually overrides a supertype method\n" + |
8947 |
"----------\n"; |
8948 |
this.runNegativeTest( |
8949 |
true, |
8950 |
testString, |
8951 |
null, customOptions, |
8952 |
expectedOutput, |
8953 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8954 |
} else { |
8955 |
this.runConformTest( |
8956 |
true, testString, |
8957 |
null, |
8958 |
customOptions, |
8959 |
null, |
8960 |
null, null, |
8961 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8962 |
} |
8963 |
} |
8964 |
|
8965 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=163194 |
8966 |
// To check Missing override annotation error when a method simply overrides |
8967 |
public void test271c() { |
8968 |
String testString [] = new String[] { |
8969 |
"B.java", |
8970 |
"interface A {\n" + |
8971 |
" void m();\n" + |
8972 |
"}\n" + |
8973 |
"public interface B extends A {\n" + |
8974 |
" void m();\n" + |
8975 |
"}\n" |
8976 |
}; |
8977 |
Map customOptions = getCompilerOptions(); |
8978 |
customOptions.put( |
8979 |
CompilerOptions.OPTION_ReportMissingOverrideAnnotation, |
8980 |
CompilerOptions.ERROR); |
8981 |
customOptions.put( |
8982 |
CompilerOptions.OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation, |
8983 |
CompilerOptions.ENABLED); |
8984 |
if (new CompilerOptions(customOptions).sourceLevel >= ClassFileConstants.JDK1_6) { |
8985 |
String expectedOutput = |
8986 |
"----------\n" + |
8987 |
"1. ERROR in B.java (at line 5)\n" + |
8988 |
" void m();\n" + |
8989 |
" ^^^\n" + |
8990 |
"The method m() of type B should be tagged with @Override since it actually overrides a supertype method\n" + |
8991 |
"----------\n"; |
8992 |
this.runNegativeTest( |
8993 |
true, |
8994 |
testString, |
8995 |
null, customOptions, |
8996 |
expectedOutput, |
8997 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8998 |
} else { |
8999 |
this.runConformTest( |
9000 |
true, testString, |
9001 |
null, |
9002 |
customOptions, |
9003 |
null, |
9004 |
null, null, |
9005 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
9006 |
} |
9007 |
} |
9008 |
|
9009 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=163194 |
9010 |
// To check missing override annotation if the method has a signature |
9011 |
// that is override-equivalent to that of any public method declared in Object. |
9012 |
public void test271d() { |
9013 |
String testString [] = new String[] { |
9014 |
"A.java", |
9015 |
"public interface A {\n" + |
9016 |
" String toString();\n" + |
9017 |
"}\n" |
9018 |
}; |
9019 |
Map customOptions = getCompilerOptions(); |
9020 |
customOptions.put( |
9021 |
CompilerOptions.OPTION_ReportMissingOverrideAnnotation, |
9022 |
CompilerOptions.ERROR); |
9023 |
customOptions.put( |
9024 |
CompilerOptions.OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation, |
9025 |
CompilerOptions.ENABLED); |
9026 |
if (new CompilerOptions(customOptions).sourceLevel >= ClassFileConstants.JDK1_6) { |
9027 |
String expectedOutput = |
9028 |
"----------\n" + |
9029 |
"1. ERROR in A.java (at line 2)\n" + |
9030 |
" String toString();\n" + |
9031 |
" ^^^^^^^^^^\n" + |
9032 |
"The method toString() of type A should be tagged with @Override since it actually overrides a supertype method\n" + |
9033 |
"----------\n"; |
9034 |
this.runNegativeTest( |
9035 |
true, |
9036 |
testString, |
9037 |
null, customOptions, |
9038 |
expectedOutput, |
9039 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
9040 |
} else { |
9041 |
this.runConformTest( |
9042 |
true, testString, |
9043 |
null, |
9044 |
customOptions, |
9045 |
null, |
9046 |
null, null, |
9047 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
9048 |
} |
9049 |
} |
8872 |
} |
9050 |
} |