Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2012 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 47-53
Link Here
|
47 |
// Static initializer to specify tests subset using TESTS_* static variables |
47 |
// Static initializer to specify tests subset using TESTS_* static variables |
48 |
// All specified tests which do not belong to the class are skipped... |
48 |
// All specified tests which do not belong to the class are skipped... |
49 |
static { |
49 |
static { |
50 |
// TESTS_NAMES = new String[] { "test293" }; |
50 |
// TESTS_NAMES = new String[] { "testBug365437b" }; |
51 |
// TESTS_NUMBERS = new int[] { 297 }; |
51 |
// TESTS_NUMBERS = new int[] { 297 }; |
52 |
// TESTS_RANGE = new int[] { 294, -1 }; |
52 |
// TESTS_RANGE = new int[] { 294, -1 }; |
53 |
} |
53 |
} |
Lines 10148-10151
Link Here
|
10148 |
"Bla cannot be resolved to a type\n" + |
10148 |
"Bla cannot be resolved to a type\n" + |
10149 |
"----------\n"); |
10149 |
"----------\n"); |
10150 |
} |
10150 |
} |
|
|
10151 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437 |
10152 |
public void testBug365437a() { |
10153 |
Map customOptions = getCompilerOptions(); |
10154 |
customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); |
10155 |
String testFiles [] = new String[] { |
10156 |
"p/A.java", |
10157 |
"package p;\n" + |
10158 |
"import p1.*;\n" + |
10159 |
"public class A {\n" + |
10160 |
" @p1.PreDestroy\n" + |
10161 |
" private void foo1(){}\n" + |
10162 |
" @PreDestroy\n" + |
10163 |
" private void foo2(){}\n" + |
10164 |
" @SuppressWarnings(\"null\")\n" + |
10165 |
" @PostConstruct\n" + |
10166 |
" private void foo1a(){}\n" + |
10167 |
" @PostConstruct\n" + |
10168 |
" private void foo2a(){}\n" + |
10169 |
" @Deprecated" + |
10170 |
" private void foo3(){}" + |
10171 |
"}\n", |
10172 |
"p1/PreDestroy.java", |
10173 |
"package p1;\n" + |
10174 |
"public @interface PreDestroy{}", |
10175 |
"p1/PostConstruct.java", |
10176 |
"package p1;\n" + |
10177 |
"public @interface PostConstruct{}" |
10178 |
}; |
10179 |
String expectedErrorString = |
10180 |
"----------\n" + |
10181 |
"1. WARNING in p\\A.java (at line 8)\n" + |
10182 |
" @SuppressWarnings(\"null\")\n" + |
10183 |
" ^^^^^^\n" + |
10184 |
"Unnecessary @SuppressWarnings(\"null\")\n" + |
10185 |
"----------\n" + |
10186 |
"2. ERROR in p\\A.java (at line 13)\n" + |
10187 |
" @Deprecated private void foo3(){}}\n" + |
10188 |
" ^^^^^^\n" + |
10189 |
"The method foo3() from the type A is never used locally\n" + |
10190 |
"----------\n"; |
10191 |
runNegativeTest( |
10192 |
true, |
10193 |
testFiles, |
10194 |
null, |
10195 |
customOptions, |
10196 |
expectedErrorString, |
10197 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
10198 |
} |
10199 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437 |
10200 |
public void testBug365437b() { |
10201 |
Map customOptions = getCompilerOptions(); |
10202 |
customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); |
10203 |
customOptions.put(CompilerOptions.OPTION_AnnotationBasedNullAnalysis, CompilerOptions.ENABLED); |
10204 |
customOptions.put(CompilerOptions.OPTION_NonNullAnnotationName, "p.NonNull"); |
10205 |
String testFiles [] = new String[] { |
10206 |
"A.java", |
10207 |
"import javax.annotation.*;\n" + |
10208 |
"public class A {\n" + |
10209 |
" @javax.annotation.PreDestroy\n" + |
10210 |
" private void foo1(){}\n" + |
10211 |
" @PreDestroy\n" + |
10212 |
" private void foo2(){}\n" + |
10213 |
" @javax.annotation.Resource\n" + |
10214 |
" private void foo1a(){}\n" + |
10215 |
" @Resource\n" + |
10216 |
" @p.NonNull\n" + |
10217 |
" private Object foo2a(){ return new Object();}\n" + |
10218 |
" @javax.annotation.PostConstruct\n" + |
10219 |
" @Deprecated\n" + |
10220 |
" private void foo3(){}\n" + |
10221 |
" @p.NonNull\n" + |
10222 |
" private Object foo3a(){ return new Object();}\n" + |
10223 |
"}\n", |
10224 |
"p/NonNull.java", |
10225 |
"package p;\n" + |
10226 |
"import static java.lang.annotation.ElementType.*;\n" + |
10227 |
"import java.lang.annotation.*;\n" + |
10228 |
"@Target({TYPE, METHOD,PARAMETER,LOCAL_VARIABLE})\n" + |
10229 |
"public @interface NonNull {\n" + |
10230 |
"}" |
10231 |
}; |
10232 |
String expectedErrorString = |
10233 |
"----------\n" + |
10234 |
"1. ERROR in A.java (at line 16)\n" + |
10235 |
" private Object foo3a(){ return new Object();}\n" + |
10236 |
" ^^^^^^^\n" + |
10237 |
"The method foo3a() from the type A is never used locally\n" + |
10238 |
"----------\n"; |
10239 |
runNegativeTest( |
10240 |
true, |
10241 |
testFiles, |
10242 |
null, |
10243 |
customOptions, |
10244 |
expectedErrorString, |
10245 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
10246 |
} |
10247 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=365437 |
10248 |
public void testBug365437c() { |
10249 |
if (this.complianceLevel < ClassFileConstants.JDK1_7) return; |
10250 |
Map customOptions = getCompilerOptions(); |
10251 |
customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); |
10252 |
String testFiles [] = new String[] { |
10253 |
"p/A.java", |
10254 |
"package p;\n" + |
10255 |
"import p1.*;\n" + |
10256 |
"public class A {\n" + |
10257 |
" @p1.PreDestroy\n" + |
10258 |
" private void foo1(){}\n" + |
10259 |
" @PreDestroy\n" + |
10260 |
" private void foo2(){}\n" + |
10261 |
" @SuppressWarnings(\"null\")\n" + |
10262 |
" @PostConstruct\n" + |
10263 |
" private void foo1a(){}\n" + |
10264 |
" @PostConstruct\n" + |
10265 |
" private void foo2a(){}\n" + |
10266 |
" @SafeVarargs" + |
10267 |
" private final void foo3(Object... o){}" + |
10268 |
"}\n", |
10269 |
"p1/PreDestroy.java", |
10270 |
"package p1;\n" + |
10271 |
"public @interface PreDestroy{}", |
10272 |
"p1/PostConstruct.java", |
10273 |
"package p1;\n" + |
10274 |
"public @interface PostConstruct{}" |
10275 |
}; |
10276 |
String expectedErrorString = |
10277 |
"----------\n" + |
10278 |
"1. WARNING in p\\A.java (at line 8)\n" + |
10279 |
" @SuppressWarnings(\"null\")\n" + |
10280 |
" ^^^^^^\n" + |
10281 |
"Unnecessary @SuppressWarnings(\"null\")\n" + |
10282 |
"----------\n" + |
10283 |
"2. ERROR in p\\A.java (at line 13)\n" + |
10284 |
" @SafeVarargs private final void foo3(Object... o){}}\n" + |
10285 |
" ^^^^^^^^^^^^^^^^^\n" + |
10286 |
"The method foo3(Object...) from the type A is never used locally\n" + |
10287 |
"----------\n"; |
10288 |
runNegativeTest( |
10289 |
true, |
10290 |
testFiles, |
10291 |
null, |
10292 |
customOptions, |
10293 |
expectedErrorString, |
10294 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
10295 |
} |
10151 |
} |
10296 |
} |