View | Details | Raw Unified | Return to bug 124533 | Differences between
and this patch

Collapse All | Expand All

(-)batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (-5 / +7 lines)
Lines 96-110 Link Here
96
\    -cp -classpath <directories and zip/jar files separated by {0}>\n\
96
\    -cp -classpath <directories and zip/jar files separated by {0}>\n\
97
\                       specify location for application classes and sources. Each\n\
97
\                       specify location for application classes and sources. Each\n\
98
\                       directory or file can specify access rules for types between\n\
98
\                       directory or file can specify access rules for types between\n\
99
\                       ''['' and '']'' (e.g. [-X.java] to deny access to type X)\n\
99
\                       ''['' and '']'' (e.g. [-X] to forbid access to type X, [~X] to\n\
100
\                       discourage access to type X, [+p/X:-p/*] to forbid access to all\n\
101
\                       types in package p but allow access to p/X)\n\
100
\    -bootclasspath <directories and zip/jar files separated by {0}>\n\
102
\    -bootclasspath <directories and zip/jar files separated by {0}>\n\
101
\                       specify location for system classes. Each directory or file can\n\
103
\                       specify location for system classes. Each directory or file can\n\
102
\                       specify access rules for types between ''['' and '']'' (e.g. [-X.java]\n\
104
\                       specify access rules for types between ''['' and '']''\n\
103
\                       to deny access to type X)\n\
104
\    -sourcepath <directories separated by {0}>\n\
105
\    -sourcepath <directories separated by {0}>\n\
105
\                       specify location for application sources. Each directory can\n\
106
\                       specify location for application sources. Each directory can\n\
106
\                       specify access rules for types between ''['' and '']'' (e.g. [-X.java]\n\
107
\                       specify access rules for types between ''['' and '']''\n\
107
\                       to deny access to type X)\n\
108
\    -extdirs <directories separated by {0}>\n\
108
\    -extdirs <directories separated by {0}>\n\
109
\                       specify location for extension zip/jar files\n\
109
\                       specify location for extension zip/jar files\n\
110
\    -d <dir>           destination directory (if omitted, no directory is created)\n\
110
\    -d <dir>           destination directory (if omitted, no directory is created)\n\
Lines 136-146 Link Here
136
\      constructorName    + method with constructor name\n\
136
\      constructorName    + method with constructor name\n\
137
\      dep-ann              missing @Deprecated annotation\n\
137
\      dep-ann              missing @Deprecated annotation\n\
138
\      deprecation        + deprecation outside deprecated code\n\
138
\      deprecation        + deprecation outside deprecated code\n\
139
\      discouraged        + use of types matching a discouraged access rule\n\
139
\      emptyBlock           undocumented empty block\n\
140
\      emptyBlock           undocumented empty block\n\
140
\      enumSwitch           incomplete enum switch\n\
141
\      enumSwitch           incomplete enum switch\n\
141
\      fieldHiding          field hiding another variable\n\
142
\      fieldHiding          field hiding another variable\n\
142
\      finalBound           type parameter with final bound\n\
143
\      finalBound           type parameter with final bound\n\
143
\      finally            + finally block not completing normally\n\
144
\      finally            + finally block not completing normally\n\
145
\      forbidden          + use of types matching a forbidden access rule\n\
144
\      hiding               macro for fieldHiding, localHiding, typeHiding and maskedCatchBlock\n\
146
\      hiding               macro for fieldHiding, localHiding, typeHiding and maskedCatchBlock\n\
145
\      incomplete-switch    same as enumSwitch\n\
147
\      incomplete-switch    same as enumSwitch\n\
146
\      indirectStatic       indirect reference to static member\n\
148
\      indirectStatic       indirect reference to static member\n\
(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (+8 lines)
Lines 1920-1925 Link Here
1920
						this.options.put(
1920
						this.options.put(
1921
							CompilerOptions.OPTION_ReportParameterAssignment,
1921
							CompilerOptions.OPTION_ReportParameterAssignment,
1922
							isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
1922
							isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
1923
					} else if (token.equals("discouraged")) { //$NON-NLS-1$
1924
						this.options.put(
1925
							CompilerOptions.OPTION_ReportDiscouragedReference,
1926
							isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
1927
					} else if (token.equals("forbidden")) { //$NON-NLS-1$
1928
						this.options.put(
1929
							CompilerOptions.OPTION_ReportForbiddenReference,
1930
							isEnabling ? CompilerOptions.WARNING : CompilerOptions.IGNORE);
1923
					} else {
1931
					} else {
1924
						throw new InvalidInputException(Main.bind("configure.invalidWarning", token)); //$NON-NLS-1$
1932
						throw new InvalidInputException(Main.bind("configure.invalidWarning", token)); //$NON-NLS-1$
1925
					}
1933
					}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+192 lines)
Lines 2213-2218 Link Here
2213
        false);
2213
        false);
2214
}
2214
}
2215
2215
2216
// check we get appropriate combination of access rules
2217
public void test040(){
2218
	this.runConformTest(
2219
		new String[] {
2220
			"p/X.java",
2221
			"package p;\n" + 
2222
			"/** */\n" + 
2223
			"public class X {\n" + 
2224
			"}",
2225
			"p/Z.java",
2226
			"package p;\n" + 
2227
			"/** */\n" + 
2228
			"public class Z {\n" + 
2229
			"}"			
2230
		},
2231
        "\"" + OUTPUT_DIR +  File.separator + "p"  +  File.separator + "X.java\""
2232
        + " \"" + OUTPUT_DIR +  File.separator + "p"  +  File.separator + "Z.java\""
2233
        + " -1.5 -g -preserveAllLocals"
2234
        + " -nowarn"
2235
        + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
2236
        "", 
2237
        "",
2238
        true);
2239
	this.runConformTest(
2240
		new String[] {
2241
			"Y.java",
2242
			"/** */\n" + 
2243
			"public class Y {\n" +
2244
			"  p.X x;\n" + 
2245
			"  p.Z z;\n" + 
2246
			"}",
2247
		},
2248
        "\"" + OUTPUT_DIR +  File.separator + "Y.java\""
2249
        + " -1.5 -g -preserveAllLocals"
2250
        + " -cp \"" + OUTPUT_DIR + "[+p/X" + File.pathSeparator + "-p/*]\""
2251
        + " -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal"
2252
        + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
2253
        "", 
2254
		"----------\n" + 
2255
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/Y.java\n" + 
2256
		" (at line 4)\n" + 
2257
		"	p.Z z;\n" + 
2258
		"	^^^\n" + 
2259
		"Access restriction: Z\n" + 
2260
		"----------\n" + 
2261
		"1 problem (1 warning)",
2262
        false);
2263
}
2264
2265
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=124533
2266
// turn off discouraged references warnings
2267
public void test041(){
2268
	this.runConformTest(
2269
		new String[] {
2270
			"p/X.java",
2271
			"package p;\n" + 
2272
			"/** */\n" + 
2273
			"public class X {\n" + 
2274
			"}",
2275
			"p/Z.java",
2276
			"package p;\n" + 
2277
			"/** */\n" + 
2278
			"public class Z {\n" + 
2279
			"}"			
2280
		},
2281
        "\"" + OUTPUT_DIR +  File.separator + "p"  +  File.separator + "X.java\""
2282
        + " \"" + OUTPUT_DIR +  File.separator + "p"  +  File.separator + "Z.java\""
2283
        + " -1.5 -g -preserveAllLocals"
2284
        + " -nowarn"
2285
        + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
2286
        "", 
2287
        "",
2288
        true);
2289
	this.runConformTest(
2290
		new String[] {
2291
			"Y.java",
2292
			"/** */\n" + 
2293
			"public class Y {\n" +
2294
			"  p.X x;\n" + 
2295
			"  p.Z z;\n" + 
2296
			"}",
2297
		},
2298
        "\"" + OUTPUT_DIR +  File.separator + "Y.java\""
2299
        + " -1.5 -g -preserveAllLocals"
2300
        + " -cp \"" + OUTPUT_DIR + "[~p/X" + File.pathSeparator + "-p/*]\""
2301
        + " -warn:-discouraged -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal"
2302
        + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
2303
        "", 
2304
		"----------\n" + 
2305
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/Y.java\n" + 
2306
		" (at line 4)\n" + 
2307
		"	p.Z z;\n" + 
2308
		"	^^^\n" + 
2309
		"Access restriction: Z\n" + 
2310
		"----------\n" + 
2311
		"1 problem (1 warning)",
2312
        false);
2313
}
2314
2315
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=124533
2316
// turn off discouraged references warnings
2317
public void test042(){
2318
	this.runConformTest(
2319
		new String[] {
2320
			"p/X.java",
2321
			"package p;\n" + 
2322
			"/** */\n" + 
2323
			"public class X {\n" + 
2324
			"}",
2325
			"p/Z.java",
2326
			"package p;\n" + 
2327
			"/** */\n" + 
2328
			"public class Z {\n" + 
2329
			"}"			
2330
		},
2331
        "\"" + OUTPUT_DIR +  File.separator + "p"  +  File.separator + "X.java\""
2332
        + " \"" + OUTPUT_DIR +  File.separator + "p"  +  File.separator + "Z.java\""
2333
        + " -1.5 -g -preserveAllLocals"
2334
        + " -nowarn"
2335
        + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
2336
        "", 
2337
        "",
2338
        true);
2339
	this.runConformTest(
2340
		new String[] {
2341
			"Y.java",
2342
			"/** */\n" + 
2343
			"public class Y {\n" +
2344
			"  p.X x;\n" + 
2345
			"  p.Z z;\n" + 
2346
			"}",
2347
		},
2348
        "\"" + OUTPUT_DIR +  File.separator + "Y.java\""
2349
        + " -1.5 -g -preserveAllLocals"
2350
        + " -cp \"" + OUTPUT_DIR + "[~p/X" + File.pathSeparator + "-p/*]\""
2351
        + " -warn:-forbidden -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal"
2352
        + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
2353
        "", 
2354
		"----------\n" + 
2355
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/Y.java\n" + 
2356
		" (at line 3)\n" + 
2357
		"	p.X x;\n" + 
2358
		"	^^^\n" + 
2359
		"Discouraged access: X\n" + 
2360
		"----------\n" + 
2361
		"1 problem (1 warning)",
2362
        false);
2363
}
2364
2365
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=124533
2366
// turn off discouraged references warnings
2367
public void test043(){
2368
	this.runConformTest(
2369
		new String[] {
2370
			"p/X.java",
2371
			"package p;\n" + 
2372
			"/** */\n" + 
2373
			"public class X {\n" + 
2374
			"}",
2375
			"p/Z.java",
2376
			"package p;\n" + 
2377
			"/** */\n" + 
2378
			"public class Z {\n" + 
2379
			"}"			
2380
		},
2381
        "\"" + OUTPUT_DIR +  File.separator + "p"  +  File.separator + "X.java\""
2382
        + " \"" + OUTPUT_DIR +  File.separator + "p"  +  File.separator + "Z.java\""
2383
        + " -1.5 -g -preserveAllLocals"
2384
        + " -nowarn"
2385
        + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
2386
        "", 
2387
        "",
2388
        true);
2389
	this.runConformTest(
2390
		new String[] {
2391
			"Y.java",
2392
			"/** */\n" + 
2393
			"public class Y {\n" +
2394
			"  p.X x;\n" + 
2395
			"  p.Z z;\n" + 
2396
			"}",
2397
		},
2398
        "\"" + OUTPUT_DIR +  File.separator + "Y.java\""
2399
        + " -1.5 -g -preserveAllLocals"
2400
        + " -cp \"" + OUTPUT_DIR + "[~p/X" + File.pathSeparator + "-p/*]\""
2401
        + " -warn:-discouraged,forbidden -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal"
2402
        + " -proceedOnError -referenceInfo -d \"" + OUTPUT_DIR + "\"",
2403
        "", 
2404
		"",
2405
        false);
2406
}
2407
2216
public static Class testClass() {
2408
public static Class testClass() {
2217
	return BatchCompilerTest.class;
2409
	return BatchCompilerTest.class;
2218
}
2410
}

Return to bug 124533