Lines 796-801
Link Here
|
796 |
// javac options |
796 |
// javac options |
797 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */); |
797 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */); |
798 |
} |
798 |
} |
|
|
799 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247206 |
800 |
public void test020() { |
801 |
Map customOptions = new HashMap(); |
802 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); |
803 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.IGNORE); |
804 |
|
805 |
this.runConformTest( |
806 |
new String[] { |
807 |
"test1/E.java", |
808 |
"package test1;\n" + |
809 |
"\n" + |
810 |
"public class E implements I {\n" + |
811 |
" public I2 foo() {\n" + |
812 |
" return null;\n" + |
813 |
" }\n" + |
814 |
"}\n" + |
815 |
"interface I {\n" + |
816 |
" /** @deprecated */\n" + |
817 |
" public I2 foo();\n" + |
818 |
"}\n" + |
819 |
"/** @deprecated */\n" + |
820 |
"interface I2 {}", |
821 |
}, |
822 |
"", // expected output |
823 |
null, |
824 |
true, // flush previous output dir content |
825 |
null, // special vm args |
826 |
customOptions, // custom options |
827 |
null); // custom requestor |
828 |
} |
829 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=247206 |
830 |
public void test021() { |
831 |
Map customOptions = new HashMap(); |
832 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); |
833 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.IGNORE); |
834 |
|
835 |
this.runConformTest( |
836 |
new String[] { |
837 |
"test1/E.java", |
838 |
"package test1;\n" + |
839 |
"\n" + |
840 |
"public class E implements I {\n" + |
841 |
" public I2 foo() {\n" + |
842 |
" return null;\n" + |
843 |
" }\n" + |
844 |
"}\n" + |
845 |
"interface I {\n" + |
846 |
" /** @deprecated */\n" + |
847 |
" public I2 foo();\n" + |
848 |
"}\n", |
849 |
"test1/I2.java", |
850 |
"package test1;\n" + |
851 |
"/** @deprecated */\n" + |
852 |
"interface I2 {}", |
853 |
}, |
854 |
"", // expected output |
855 |
null, |
856 |
true, // flush previous output dir content |
857 |
null, // special vm args |
858 |
customOptions, // custom options |
859 |
null); // custom requestor |
860 |
} |
861 |
|
862 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=247206, additional tests that verify that |
863 |
// deprecation messages originate from type parameters, bounds, arguments, return types, |
864 |
// local variables, exception specifications etc. Valid only for 1.5 and above |
865 |
public void test022() { |
866 |
if (this.complianceLevel <= ClassFileConstants.JDK1_4) |
867 |
return; |
868 |
Map customOptions = new HashMap(); |
869 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); |
870 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.ENABLED); |
871 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.IGNORE); |
872 |
|
873 |
this.runNegativeTest( |
874 |
// test directory preparation |
875 |
true /* flush output directory */, |
876 |
new String[] { |
877 |
"test1/E.java", |
878 |
"package test1;\n" + |
879 |
"\n" + |
880 |
"public class E implements I {\n" + |
881 |
" public <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
882 |
" I2 p = null; \n" + |
883 |
" return p;\n" + |
884 |
" }\n" + |
885 |
"}\n" + |
886 |
"interface I {\n" + |
887 |
" /** @deprecated */\n" + |
888 |
" public <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception;\n" + |
889 |
"}\n", |
890 |
"test1/I2.java", |
891 |
"package test1;\n" + |
892 |
"/** @deprecated */\n" + |
893 |
"interface I2 { /** @deprecated */ interface I3 {} }\n" + |
894 |
"/** @deprecated */\n" + |
895 |
"class Xception extends Throwable {\n" + |
896 |
" private static final long serialVersionUID = 1L;\n}\n", |
897 |
}, |
898 |
// compiler options |
899 |
null /* no class libraries */, |
900 |
customOptions /* custom options */, |
901 |
"----------\n" + // expected output |
902 |
"1. ERROR in test1\\E.java (at line 4)\n" + |
903 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
904 |
"\t ^^\n" + |
905 |
"The type I2 is deprecated\n" + |
906 |
"----------\n" + |
907 |
"2. ERROR in test1\\E.java (at line 4)\n" + |
908 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
909 |
"\t ^^^^^\n" + |
910 |
"The type I2 is deprecated\n" + |
911 |
"----------\n" + |
912 |
"3. ERROR in test1\\E.java (at line 4)\n" + |
913 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
914 |
"\t ^^^^^\n" + |
915 |
"The type I2.I3 is deprecated\n" + |
916 |
"----------\n" + |
917 |
"4. ERROR in test1\\E.java (at line 4)\n" + |
918 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
919 |
"\t ^^\n" + |
920 |
"The type I2 is deprecated\n" + |
921 |
"----------\n" + |
922 |
"5. ERROR in test1\\E.java (at line 4)\n" + |
923 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
924 |
"\t ^^\n" + |
925 |
"The type I2 is deprecated\n" + |
926 |
"----------\n" + |
927 |
"6. ERROR in test1\\E.java (at line 4)\n" + |
928 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
929 |
"\t ^^^^^^^^\n" + |
930 |
"The type Xception is deprecated\n" + |
931 |
"----------\n" + |
932 |
"7. ERROR in test1\\E.java (at line 5)\n" + |
933 |
"\tI2 p = null; \n" + |
934 |
"\t^^\n" + |
935 |
"The type I2 is deprecated\n" + |
936 |
"----------\n" + |
937 |
"8. ERROR in test1\\E.java (at line 11)\n" + |
938 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception;\n" + |
939 |
"\t ^^\n" + |
940 |
"The type I2 is deprecated\n" + |
941 |
"----------\n" + |
942 |
"9. ERROR in test1\\E.java (at line 11)\n" + |
943 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception;\n" + |
944 |
"\t ^^^^^\n" + |
945 |
"The type I2 is deprecated\n" + |
946 |
"----------\n" + |
947 |
"10. ERROR in test1\\E.java (at line 11)\n" + |
948 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception;\n" + |
949 |
"\t ^^^^^\n" + |
950 |
"The type I2.I3 is deprecated\n" + |
951 |
"----------\n" + |
952 |
"11. ERROR in test1\\E.java (at line 11)\n" + |
953 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception;\n" + |
954 |
"\t ^^\n" + |
955 |
"The type I2 is deprecated\n" + |
956 |
"----------\n" + |
957 |
"12. ERROR in test1\\E.java (at line 11)\n" + |
958 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception;\n" + |
959 |
"\t ^^\n" + |
960 |
"The type I2 is deprecated\n" + |
961 |
"----------\n" + |
962 |
"13. ERROR in test1\\E.java (at line 11)\n" + |
963 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception;\n" + |
964 |
"\t ^^^^^^^^\n" + |
965 |
"The type Xception is deprecated\n" + |
966 |
"----------\n", |
967 |
// javac options |
968 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */ |
969 |
); |
970 |
} |
971 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=247206, verify that none of the 13 errros produced |
972 |
// by test022 show up when deprecation reporting in an already deprecated context is disabled. |
973 |
public void test023() { |
974 |
if (this.complianceLevel <= ClassFileConstants.JDK1_4) |
975 |
return; |
976 |
Map customOptions = new HashMap(); |
977 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); |
978 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.DISABLED); |
979 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.IGNORE); |
980 |
|
981 |
this.runConformTest( |
982 |
new String[] { |
983 |
"test1/E.java", |
984 |
"package test1;\n" + |
985 |
"\n" + |
986 |
"public class E implements I {\n" + |
987 |
" public <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
988 |
" I2 p = null; \n" + |
989 |
" return p;\n" + |
990 |
" }\n" + |
991 |
"}\n" + |
992 |
"interface I {\n" + |
993 |
" /** @deprecated */\n" + |
994 |
" public <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception;\n" + |
995 |
"}\n", |
996 |
"test1/I2.java", |
997 |
"package test1;\n" + |
998 |
"/** @deprecated */\n" + |
999 |
"interface I2 { /** @deprecated */ interface I3 {} }\n" + |
1000 |
"/** @deprecated */\n" + |
1001 |
"class Xception extends Throwable {\n" + |
1002 |
" private static final long serialVersionUID = 1L;\n}\n", |
1003 |
}, |
1004 |
"", // expected output |
1005 |
null, |
1006 |
true, // flush previous output dir content |
1007 |
null, // special vm args |
1008 |
customOptions, // custom options |
1009 |
null); // custom requestor |
1010 |
} |
1011 |
|
1012 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=247206, Note : foo in class E is not overriding |
1013 |
// foo in interface I in this test. It is a new method and as such is not deprecated implicitly. |
1014 |
public void test024() { |
1015 |
if (this.complianceLevel <= ClassFileConstants.JDK1_4) |
1016 |
return; |
1017 |
Map customOptions = new HashMap(); |
1018 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); |
1019 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.DISABLED); |
1020 |
customOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.IGNORE); |
1021 |
|
1022 |
this.runNegativeTest( |
1023 |
// test directory preparation |
1024 |
true /* flush output directory */, |
1025 |
new String[] { |
1026 |
"test1/E.java", |
1027 |
"package test1;\n" + |
1028 |
"\n" + |
1029 |
"public abstract class E implements I {\n" + |
1030 |
" public <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
1031 |
" I2 p = null; \n" + |
1032 |
" return p;\n" + |
1033 |
" }\n" + |
1034 |
"}\n" + |
1035 |
"interface I {\n" + |
1036 |
" /** @deprecated */\n" + |
1037 |
" public <T extends I2 & I2.I3> I2 foo() throws Xception;\n" + |
1038 |
"}\n", |
1039 |
"test1/I2.java", |
1040 |
"package test1;\n" + |
1041 |
"/** @deprecated */\n" + |
1042 |
"interface I2 { /** @deprecated */ interface I3 {} }\n" + |
1043 |
"/** @deprecated */\n" + |
1044 |
"class Xception extends Throwable {\n" + |
1045 |
" private static final long serialVersionUID = 1L;\n}\n", |
1046 |
}, |
1047 |
// compiler options |
1048 |
null /* no class libraries */, |
1049 |
customOptions /* custom options */, |
1050 |
"----------\n" + |
1051 |
"1. ERROR in test1\\E.java (at line 4)\n" + |
1052 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
1053 |
"\t ^^\n" + |
1054 |
"The type I2 is deprecated\n" + |
1055 |
"----------\n" + |
1056 |
"2. ERROR in test1\\E.java (at line 4)\n" + |
1057 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
1058 |
"\t ^^^^^\n" + |
1059 |
"The type I2.I3 is deprecated\n" + |
1060 |
"----------\n" + |
1061 |
"3. ERROR in test1\\E.java (at line 4)\n" + |
1062 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
1063 |
"\t ^^^^^\n" + |
1064 |
"The type I2 is deprecated\n" + |
1065 |
"----------\n" + |
1066 |
"4. ERROR in test1\\E.java (at line 4)\n" + |
1067 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
1068 |
"\t ^^\n" + |
1069 |
"The type I2 is deprecated\n" + |
1070 |
"----------\n" + |
1071 |
"5. ERROR in test1\\E.java (at line 4)\n" + |
1072 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
1073 |
"\t ^^\n" + |
1074 |
"The type I2 is deprecated\n" + |
1075 |
"----------\n" + |
1076 |
"6. ERROR in test1\\E.java (at line 4)\n" + |
1077 |
"\tpublic <T extends I2 & I2.I3> I2 foo(I2 i2) throws Xception {\n" + |
1078 |
"\t ^^^^^^^^\n" + |
1079 |
"The type Xception is deprecated\n" + |
1080 |
"----------\n" + |
1081 |
"7. ERROR in test1\\E.java (at line 5)\n" + |
1082 |
"\tI2 p = null; \n" + |
1083 |
"\t^^\n" + |
1084 |
"The type I2 is deprecated\n" + |
1085 |
"----------\n", |
1086 |
// javac options |
1087 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */ |
1088 |
); |
1089 |
} |
1090 |
|
799 |
public static Class testClass() { |
1091 |
public static Class testClass() { |
800 |
return DeprecatedTest.class; |
1092 |
return DeprecatedTest.class; |
801 |
} |
1093 |
} |