Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 375366
Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (-1 / +125 lines)
Lines 19-24 Link Here
19
 *								bug 370639 - [compiler][resource] restore the default for resource leak warnings
19
 *								bug 370639 - [compiler][resource] restore the default for resource leak warnings
20
 *								bug 365859 - [compiler][null] distinguish warnings based on flow analysis vs. null annotations
20
 *								bug 365859 - [compiler][null] distinguish warnings based on flow analysis vs. null annotations
21
 *								bug 374605 - Unreasonable warning for enum-based switch statements
21
 *								bug 374605 - Unreasonable warning for enum-based switch statements
22
 *								bug 375366 - ECJ ignores unusedParameterIncludeDocCommentReference unless enableJavadoc option is set
22
 *******************************************************************************/
23
 *******************************************************************************/
23
package org.eclipse.jdt.core.tests.compiler.regression;
24
package org.eclipse.jdt.core.tests.compiler.regression;
24
25
Lines 81-87 Link Here
81
			"}\n";
82
			"}\n";
82
83
83
	static {
84
	static {
84
//		TESTS_NAMES = new String[] { "testBug375409e" };
85
//		TESTS_NAMES = new String[] { "testBug375366" };
85
//		TESTS_NUMBERS = new int[] { 306 };
86
//		TESTS_NUMBERS = new int[] { 306 };
86
//		TESTS_RANGE = new int[] { 298, -1 };
87
//		TESTS_RANGE = new int[] { 298, -1 };
87
	}
88
	}
Lines 13467-13470 Link Here
13467
		"", 
13468
		"", 
13468
		true);
13469
		true);
13469
}
13470
}
13471
// Bug 375366 - ECJ ignores unusedParameterIncludeDocCommentReference unless enableJavadoc option is set
13472
// when -properties is used process javadoc by default
13473
public void testBug375366a() throws IOException {
13474
	createOutputTestDirectory("regression/.settings");
13475
	Util.createFile(OUTPUT_DIR+"/.settings/org.eclipse.jdt.core.prefs",
13476
			"eclipse.preferences.version=1\n" + 
13477
			"org.eclipse.jdt.core.compiler.problem.unusedParameter=warning\n");
13478
	this.runConformTest(
13479
		new String[] {
13480
			"bugs/warning/ShowBug.java",
13481
			"package bugs.warning;\n" + 
13482
			"\n" + 
13483
			"public class ShowBug {\n" + 
13484
			"	/**\n" + 
13485
			"	 * \n" + 
13486
			"	 * @param unusedParam\n" + 
13487
			"	 */\n" + 
13488
			"	public void foo(Object unusedParam) {\n" + 
13489
			"		\n" + 
13490
			"	}\n" + 
13491
			"}\n"
13492
		},
13493
		"\"" + OUTPUT_DIR +  File.separator + "bugs" + File.separator + "warning" + File.separator + "ShowBug.java\""
13494
		+ " -1.5"
13495
		+ " -properties " + OUTPUT_DIR + File.separator +".settings" + File.separator + "org.eclipse.jdt.core.prefs "
13496
		+ " -d \"" + OUTPUT_DIR + "\"",
13497
		"",
13498
		"", 
13499
		false /*don't flush output dir*/);
13500
}
13501
13502
// Bug 375366 - ECJ ignores unusedParameterIncludeDocCommentReference unless enableJavadoc option is set
13503
// property file explicitly disables javadoc processing
13504
public void testBug375366b() throws IOException {
13505
	createOutputTestDirectory("regression/.settings");
13506
	Util.createFile(OUTPUT_DIR+"/.settings/org.eclipse.jdt.core.prefs",
13507
			"eclipse.preferences.version=1\n" + 
13508
			"org.eclipse.jdt.core.compiler.problem.unusedParameter=warning\n" +
13509
			"org.eclipse.jdt.core.compiler.doc.comment.support=disabled\n");
13510
	this.runTest(
13511
		true, // compile OK, expecting only warning
13512
		new String[] {
13513
			"bugs/warning/ShowBug.java",
13514
			"package bugs.warning;\n" + 
13515
			"\n" + 
13516
			"public class ShowBug {\n" + 
13517
			"	/**\n" + 
13518
			"	 * \n" + 
13519
			"	 * @param unusedParam\n" + 
13520
			"	 */\n" + 
13521
			"	public void foo(Object unusedParam) {\n" + 
13522
			"		\n" + 
13523
			"	}\n" + 
13524
			"}\n"
13525
		},
13526
		"\"" + OUTPUT_DIR +  File.separator + "bugs" + File.separator + "warning" + File.separator + "ShowBug.java\""
13527
		+ " -1.5"
13528
		+ " -properties " + OUTPUT_DIR + File.separator +".settings" + File.separator + "org.eclipse.jdt.core.prefs "
13529
		+ " -d \"" + OUTPUT_DIR + "\"",
13530
		"", 
13531
		"----------\n" + 
13532
		"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/bugs/warning/ShowBug.java (at line 8)\n" + 
13533
		"	public void foo(Object unusedParam) {\n" + 
13534
		"	                       ^^^^^^^^^^^\n" + 
13535
		"The value of the parameter unusedParam is not used\n" + 
13536
		"----------\n" + 
13537
		"1 problem (1 warning)",
13538
		false /*don't flush output dir*/,
13539
		null /* progress */);
13540
}
13541
13542
// Bug 375366 - ECJ ignores unusedParameterIncludeDocCommentReference unless enableJavadoc option is set
13543
// property file enables null annotation support
13544
public void testBug375366c() throws IOException {
13545
	createOutputTestDirectory("regression/.settings");
13546
	Util.createFile(OUTPUT_DIR+"/.settings/org.eclipse.jdt.core.prefs",
13547
			"eclipse.preferences.version=1\n" + 
13548
			"org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled\n");
13549
	this.runNegativeTest(
13550
			new String[] {
13551
					"p/X.java",
13552
					"package p;\n" +
13553
					"import org.eclipse.jdt.annotation.*;\n" +
13554
					"public class X {\n" +
13555
					"  @NonNull Object foo(@Nullable Object o, @NonNull Object o2) {\n" +
13556
					"	 return this;\n" +
13557
					"  }\n" +
13558
					"}\n" +
13559
					"class Y extends X {\n" +
13560
					"    @Nullable Object foo(Object o, Object o2) { return null; }\n" +
13561
					"}\n",
13562
					"org/eclipse/jdt/annotation/NonNull.java",
13563
					NONNULL_ANNOTATION_CONTENT,
13564
					"org/eclipse/jdt/annotation/Nullable.java",
13565
					NULLABLE_ANNOTATION_CONTENT,
13566
					"org/eclipse/jdt/annotation/NonNullByDefault.java",				
13567
					NONNULL_BY_DEFAULT_ANNOTATION_CONTENT
13568
			},
13569
			"\"" + OUTPUT_DIR +  File.separator + "p" + File.separator + "X.java\""
13570
			+ " -sourcepath \"" + OUTPUT_DIR + "\""
13571
			+ " -1.5"
13572
			+ " -properties " + OUTPUT_DIR + File.separator +".settings" + File.separator + "org.eclipse.jdt.core.prefs "
13573
			+ " -d \"" + OUTPUT_DIR + "\"",
13574
			"",
13575
			"----------\n" + 
13576
			"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" + 
13577
			"	@Nullable Object foo(Object o, Object o2) { return null; }\n" + 
13578
			"	^^^^^^^^^^^^^^^^\n" + 
13579
			"The return type is incompatible with the @NonNull return from X.foo(Object, Object)\n" + 
13580
			"----------\n" + 
13581
			"2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" + 
13582
			"	@Nullable Object foo(Object o, Object o2) { return null; }\n" + 
13583
			"	                     ^^^^^^\n" + 
13584
			"Missing nullable annotation: inherited method from X declares this parameter as @Nullable\n" + 
13585
			"----------\n" + 
13586
			"3. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" + 
13587
			"	@Nullable Object foo(Object o, Object o2) { return null; }\n" + 
13588
			"	                               ^^^^^^\n" + 
13589
			"Missing non-null annotation: inherited method from X declares this parameter as @NonNull\n" + 
13590
			"----------\n" + 
13591
			"3 problems (3 errors)", 
13592
			false/*don't flush*/);
13593
}
13470
}
13594
}
(-)a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java (-1 / +15 lines)
Lines 16-21 Link Here
16
 *     							bug 359721 - [options] add command line option for new warning token "resource"
16
 *     							bug 359721 - [options] add command line option for new warning token "resource"
17
 *								bug 365208 - [compiler][batch] command line options for annotation based null analysis
17
 *								bug 365208 - [compiler][batch] command line options for annotation based null analysis
18
 *								bug 374605 - Unreasonable warning for enum-based switch statements
18
 *								bug 374605 - Unreasonable warning for enum-based switch statements
19
 *								bug 375366 - ECJ ignores unusedParameterIncludeDocCommentReference unless enableJavadoc option is set
19
 *******************************************************************************/
20
 *******************************************************************************/
20
package org.eclipse.jdt.internal.compiler.batch;
21
package org.eclipse.jdt.internal.compiler.batch;
21
22
Lines 2858-2867 Link Here
2858
	for (Iterator iterator = properties.entrySet().iterator(); iterator.hasNext(); ) {
2859
	for (Iterator iterator = properties.entrySet().iterator(); iterator.hasNext(); ) {
2859
		Map.Entry entry = (Map.Entry) iterator.next();
2860
		Map.Entry entry = (Map.Entry) iterator.next();
2860
		final String key = (String) entry.getKey();
2861
		final String key = (String) entry.getKey();
2861
		if (key.startsWith("org.eclipse.jdt.core.compiler.problem")) { //$NON-NLS-1$
2862
		if (key.startsWith("org.eclipse.jdt.core.compiler.")) { //$NON-NLS-1$
2862
			this.options.put(key, entry.getValue());
2863
			this.options.put(key, entry.getValue());
2863
		}
2864
		}
2864
	}
2865
	}
2866
	// when using a properties file mimic relevant defaults from JavaCorePreferenceInitializer:
2867
	if (!properties.containsKey(CompilerOptions.OPTION_LocalVariableAttribute)) {
2868
		this.options.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
2869
	}
2870
	if (!properties.containsKey(CompilerOptions.OPTION_PreserveUnusedLocal)) {
2871
		this.options.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.PRESERVE);
2872
	}
2873
	if (!properties.containsKey(CompilerOptions.OPTION_DocCommentSupport)) {
2874
		this.options.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED);
2875
	}
2876
	if (!properties.containsKey(CompilerOptions.OPTION_ReportForbiddenReference)) {
2877
		this.options.put(CompilerOptions.OPTION_ReportForbiddenReference, CompilerOptions.ERROR);
2878
	}
2865
}
2879
}
2866
protected void enableAll(int severity) {
2880
protected void enableAll(int severity) {
2867
	String newValue = null;
2881
	String newValue = null;
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java (+1 lines)
Lines 29-34 Link Here
29
	 */
29
	 */
30
	public void initializeDefaultPreferences() {
30
	public void initializeDefaultPreferences() {
31
		// If modified, also modify the method JavaModelManager#getDefaultOptionsNoInitialization()
31
		// If modified, also modify the method JavaModelManager#getDefaultOptionsNoInitialization()
32
		// and also consider updating org.eclipse.jdt.internal.compiler.batch.Main#initializeWarnings(String)
32
		// Get options names set
33
		// Get options names set
33
		HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames;
34
		HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames;
34
35

Return to bug 375366