### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v retrieving revision 1.314 diff -u -r1.314 Main.java --- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 8 Nov 2007 16:59:56 -0000 1.314 +++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 29 Nov 2007 12:33:36 -0000 @@ -2260,7 +2260,6 @@ boolean didSpecifyDefaultEncoding = false; boolean didSpecifyDeprecation = false; - boolean didSpecifyWarnings = false; boolean useEnableJavadoc = false; boolean didSpecifyCompliance = false; boolean didSpecifyDisabledAnnotationProcessing = false; @@ -2685,22 +2684,23 @@ this.bind("configure.invalidWarningConfiguration", warningOption)); //$NON-NLS-1$ } int warnTokenStart; - boolean isEnabling; + boolean isEnabling, allowPlusOrMinus; switch (warningOption.charAt(6)) { case '+' : warnTokenStart = 7; isEnabling = true; + allowPlusOrMinus = true; break; case '-' : warnTokenStart = 7; isEnabling = false; // mentionned warnings are disabled + allowPlusOrMinus = true; break; default: + disableWarnings(); warnTokenStart = 6; - // clear default warning level - // but allow multiple warning option on the command line - if (!didSpecifyWarnings) disableWarnings(); isEnabling = true; + allowPlusOrMinus = false; } StringTokenizer tokenizer = @@ -2711,17 +2711,27 @@ this.options.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING); } - while (tokenizer.hasMoreTokens()) { + nextToken: while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); tokenCounter++; switch(token.charAt(0)) { case '+' : - isEnabling = true; - token = token.substring(1); + if (allowPlusOrMinus) { + isEnabling = true; + token = token.substring(1); + } else { + tokenCounter = 0; + break nextToken; + } break; case '-' : - isEnabling = false; - token = token.substring(1); + if (allowPlusOrMinus) { + isEnabling = false; + token = token.substring(1); + } else { + tokenCounter = 0; + break nextToken; + } break; } handleWarningToken(token, isEnabling, useEnableJavadoc); @@ -2730,7 +2740,6 @@ throw new InvalidInputException( this.bind("configure.invalidWarningOption", currentArg)); //$NON-NLS-1$ } - didSpecifyWarnings = true; continue; } if (currentArg.equals("-target")) { //$NON-NLS-1$ #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v retrieving revision 1.138 diff -u -r1.138 BatchCompilerTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 21 Nov 2007 13:40:45 -0000 1.138 +++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 29 Nov 2007 12:33:40 -0000 @@ -5609,7 +5609,7 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=210518 // bad behavior for -warn:null -warn:unused -public void _test156_warn_options() { +public void test156_warn_options() { // same source as 153, skip default checks this.runConformTest( new String[] { @@ -7630,6 +7630,48 @@ "6 problems (6 warnings)", true); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=210518 +// variant +public void test206_warn_options() { + // same source as 153, skip default checks + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void foo() {\n" + + " String s = null;\n" + + " s.toString();\n" + + " String u;\n" + + " }\n" + + "}", + }, + "\"" + OUTPUT_DIR + File.separator + "X.java\"" + + " -warn:null,-unused -proc:none -d \"" + OUTPUT_DIR + "\"", + "", + "invalid warning option: -warn:null,-unused. Must specify a warning token\n", + true); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=210518 +// variant +public void test207_warn_options() { + // same source as 153, skip default checks + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void foo() {\n" + + " String s = null;\n" + + " s.toString();\n" + + " String u;\n" + + " }\n" + + "}", + }, + "\"" + OUTPUT_DIR + File.separator + "X.java\"" + + " -warn:null,+unused -proc:none -d \"" + OUTPUT_DIR + "\"", + "", + "invalid warning option: -warn:null,+unused. Must specify a warning token\n", + true); +} public static Class testClass() { return BatchCompilerTest.class; }