aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2012-08-25 08:31:08 (EDT)
committerJayaprakash Arthanareeswaran2012-10-19 00:49:06 (EDT)
commita09311fc616e4147742893af072d96170b7d4b0c (patch)
tree5da5513125681815a1640e6fff8ac24b6d06998f
parenta00bb5eefc5dc1b2770154375a5f65dad7ebaf03 (diff)
downloadeclipse.jdt.core-a09311fc616e4147742893af072d96170b7d4b0c.zip
eclipse.jdt.core-a09311fc616e4147742893af072d96170b7d4b0c.tar.gz
eclipse.jdt.core-a09311fc616e4147742893af072d96170b7d4b0c.tar.bz2
Bug 375366 - ECJ ignores unusedParameterIncludeDocCommentReference
unless enableJavadoc option is set Fix by - considering more options from "-properties <file>" - using a few different defaults when -properties is set. Change-Id: I3850501d781c42ef7852445057c4ca7c9ae5fe5b
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java126
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java16
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java1
3 files changed, 141 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
index 8b1573f..1b6c2ec 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
@@ -23,6 +23,7 @@
* bug 370639 - [compiler][resource] restore the default for resource leak warnings
* bug 365859 - [compiler][null] distinguish warnings based on flow analysis vs. null annotations
* bug 374605 - Unreasonable warning for enum-based switch statements
+ * bug 375366 - ECJ ignores unusedParameterIncludeDocCommentReference unless enableJavadoc option is set
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
@@ -85,7 +86,7 @@ public class BatchCompilerTest extends AbstractRegressionTest {
"}\n";
static {
-// TESTS_NAMES = new String[] { "testBug375409e" };
+// TESTS_NAMES = new String[] { "testBug375366" };
// TESTS_NUMBERS = new int[] { 306 };
// TESTS_RANGE = new int[] { 298, -1 };
}
@@ -13472,4 +13473,127 @@ public void testBug375409g() {
"",
true);
}
+// Bug 375366 - ECJ ignores unusedParameterIncludeDocCommentReference unless enableJavadoc option is set
+// when -properties is used process javadoc by default
+public void testBug375366a() throws IOException {
+ createOutputTestDirectory("regression/.settings");
+ Util.createFile(OUTPUT_DIR+"/.settings/org.eclipse.jdt.core.prefs",
+ "eclipse.preferences.version=1\n" +
+ "org.eclipse.jdt.core.compiler.problem.unusedParameter=warning\n");
+ this.runConformTest(
+ new String[] {
+ "bugs/warning/ShowBug.java",
+ "package bugs.warning;\n" +
+ "\n" +
+ "public class ShowBug {\n" +
+ " /**\n" +
+ " * \n" +
+ " * @param unusedParam\n" +
+ " */\n" +
+ " public void foo(Object unusedParam) {\n" +
+ " \n" +
+ " }\n" +
+ "}\n"
+ },
+ "\"" + OUTPUT_DIR + File.separator + "bugs" + File.separator + "warning" + File.separator + "ShowBug.java\""
+ + " -1.5"
+ + " -properties " + OUTPUT_DIR + File.separator +".settings" + File.separator + "org.eclipse.jdt.core.prefs "
+ + " -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "",
+ false /*don't flush output dir*/);
+}
+
+// Bug 375366 - ECJ ignores unusedParameterIncludeDocCommentReference unless enableJavadoc option is set
+// property file explicitly disables javadoc processing
+public void testBug375366b() throws IOException {
+ createOutputTestDirectory("regression/.settings");
+ Util.createFile(OUTPUT_DIR+"/.settings/org.eclipse.jdt.core.prefs",
+ "eclipse.preferences.version=1\n" +
+ "org.eclipse.jdt.core.compiler.problem.unusedParameter=warning\n" +
+ "org.eclipse.jdt.core.compiler.doc.comment.support=disabled\n");
+ this.runTest(
+ true, // compile OK, expecting only warning
+ new String[] {
+ "bugs/warning/ShowBug.java",
+ "package bugs.warning;\n" +
+ "\n" +
+ "public class ShowBug {\n" +
+ " /**\n" +
+ " * \n" +
+ " * @param unusedParam\n" +
+ " */\n" +
+ " public void foo(Object unusedParam) {\n" +
+ " \n" +
+ " }\n" +
+ "}\n"
+ },
+ "\"" + OUTPUT_DIR + File.separator + "bugs" + File.separator + "warning" + File.separator + "ShowBug.java\""
+ + " -1.5"
+ + " -properties " + OUTPUT_DIR + File.separator +".settings" + File.separator + "org.eclipse.jdt.core.prefs "
+ + " -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/bugs/warning/ShowBug.java (at line 8)\n" +
+ " public void foo(Object unusedParam) {\n" +
+ " ^^^^^^^^^^^\n" +
+ "The value of the parameter unusedParam is not used\n" +
+ "----------\n" +
+ "1 problem (1 warning)",
+ false /*don't flush output dir*/,
+ null /* progress */);
+}
+
+// Bug 375366 - ECJ ignores unusedParameterIncludeDocCommentReference unless enableJavadoc option is set
+// property file enables null annotation support
+public void testBug375366c() throws IOException {
+ createOutputTestDirectory("regression/.settings");
+ Util.createFile(OUTPUT_DIR+"/.settings/org.eclipse.jdt.core.prefs",
+ "eclipse.preferences.version=1\n" +
+ "org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled\n");
+ this.runNegativeTest(
+ new String[] {
+ "p/X.java",
+ "package p;\n" +
+ "import org.eclipse.jdt.annotation.*;\n" +
+ "public class X {\n" +
+ " @NonNull Object foo(@Nullable Object o, @NonNull Object o2) {\n" +
+ " return this;\n" +
+ " }\n" +
+ "}\n" +
+ "class Y extends X {\n" +
+ " @Nullable Object foo(Object o, Object o2) { return null; }\n" +
+ "}\n",
+ "org/eclipse/jdt/annotation/NonNull.java",
+ NONNULL_ANNOTATION_CONTENT,
+ "org/eclipse/jdt/annotation/Nullable.java",
+ NULLABLE_ANNOTATION_CONTENT,
+ "org/eclipse/jdt/annotation/NonNullByDefault.java",
+ NONNULL_BY_DEFAULT_ANNOTATION_CONTENT
+ },
+ "\"" + OUTPUT_DIR + File.separator + "p" + File.separator + "X.java\""
+ + " -sourcepath \"" + OUTPUT_DIR + "\""
+ + " -1.5"
+ + " -properties " + OUTPUT_DIR + File.separator +".settings" + File.separator + "org.eclipse.jdt.core.prefs "
+ + " -d \"" + OUTPUT_DIR + "\"",
+ "",
+ "----------\n" +
+ "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" +
+ " @Nullable Object foo(Object o, Object o2) { return null; }\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "The return type is incompatible with the @NonNull return from X.foo(Object, Object)\n" +
+ "----------\n" +
+ "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" +
+ " @Nullable Object foo(Object o, Object o2) { return null; }\n" +
+ " ^^^^^^\n" +
+ "Missing nullable annotation: inherited method from X declares this parameter as @Nullable\n" +
+ "----------\n" +
+ "3. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/p/X.java (at line 9)\n" +
+ " @Nullable Object foo(Object o, Object o2) { return null; }\n" +
+ " ^^^^^^\n" +
+ "Missing non-null annotation: inherited method from X declares this parameter as @NonNull\n" +
+ "----------\n" +
+ "3 problems (3 errors)",
+ false/*don't flush*/);
+}
}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
index d8c2a1c..e053b67 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
@@ -20,6 +20,7 @@
* bug 359721 - [options] add command line option for new warning token "resource"
* bug 365208 - [compiler][batch] command line options for annotation based null analysis
* bug 374605 - Unreasonable warning for enum-based switch statements
+ * bug 375366 - ECJ ignores unusedParameterIncludeDocCommentReference unless enableJavadoc option is set
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.batch;
@@ -2879,10 +2880,23 @@ private void initializeWarnings(String propertiesFile) {
for (Iterator iterator = properties.entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry entry = (Map.Entry) iterator.next();
final String key = (String) entry.getKey();
- if (key.startsWith("org.eclipse.jdt.core.compiler.problem")) { //$NON-NLS-1$
+ if (key.startsWith("org.eclipse.jdt.core.compiler.")) { //$NON-NLS-1$
this.options.put(key, entry.getValue());
}
}
+ // when using a properties file mimic relevant defaults from JavaCorePreferenceInitializer:
+ if (!properties.containsKey(CompilerOptions.OPTION_LocalVariableAttribute)) {
+ this.options.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
+ }
+ if (!properties.containsKey(CompilerOptions.OPTION_PreserveUnusedLocal)) {
+ this.options.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.PRESERVE);
+ }
+ if (!properties.containsKey(CompilerOptions.OPTION_DocCommentSupport)) {
+ this.options.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED);
+ }
+ if (!properties.containsKey(CompilerOptions.OPTION_ReportForbiddenReference)) {
+ this.options.put(CompilerOptions.OPTION_ReportForbiddenReference, CompilerOptions.ERROR);
+ }
}
protected void enableAll(int severity) {
String newValue = null;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java
index 91c6dde..fb926c3 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java
@@ -29,6 +29,7 @@ public class JavaCorePreferenceInitializer extends AbstractPreferenceInitializer
*/
public void initializeDefaultPreferences() {
// If modified, also modify the method JavaModelManager#getDefaultOptionsNoInitialization()
+ // and also consider updating org.eclipse.jdt.internal.compiler.batch.Main#initializeWarnings(String)
// Get options names set
HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames;