### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.compiler.tool Index: src/org/eclipse/jdt/internal/compiler/tool/Options.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/Options.java,v retrieving revision 1.13 diff -u -r1.13 Options.java --- src/org/eclipse/jdt/internal/compiler/tool/Options.java 24 Sep 2010 06:30:58 -0000 1.13 +++ src/org/eclipse/jdt/internal/compiler/tool/Options.java 29 Sep 2010 12:09:48 -0000 @@ -168,6 +168,7 @@ || token.equals("forbidden")//$NON-NLS-1$ || token.equals("hashCode")//$NON-NLS-1$ || token.equals("hiding")//$NON-NLS-1$ + || token.equals("includeAssertNull")//$NON-NLS-1$ || token.equals("incomplete-switch")//$NON-NLS-1$ || token.equals("indirectStatic")//$NON-NLS-1$ || token.equals("interfaceNonInherited")//$NON-NLS-1$ @@ -195,7 +196,6 @@ || token.equals("staticReceiver")//$NON-NLS-1$ || token.equals("super")//$NON-NLS-1$ || token.equals("suppress")//$NON-NLS-1$ - || token.equals("suppressAssertNull")//$NON-NLS-1$ || token.equals("syncOverride")//$NON-NLS-1$ || token.equals("synthetic-access")//$NON-NLS-1$ || token.equals("syntheticAccess")//$NON-NLS-1$ #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.354 diff -u -r1.354 Main.java --- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 24 Sep 2010 06:30:57 -0000 1.354 +++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 29 Sep 2010 12:09:50 -0000 @@ -3333,7 +3333,12 @@ } else if (token.equals("intfRedundant") /*|| token.equals("redundantSuperinterface")*/) { //$NON-NLS-1$ setSeverity(CompilerOptions.OPTION_ReportRedundantSuperinterface, severity, isEnabling); return; - } + } else if (token.equals("includeAssertNull")) { //$NON-NLS-1$ + this.options.put( + CompilerOptions.OPTION_IncludeNullInfoFromAsserts, + isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED); + return; + } break; case 'j' : if (token.equals("javadoc")) {//$NON-NLS-1$ @@ -3456,12 +3461,7 @@ } else if (token.equals("super")) { //$NON-NLS-1$ setSeverity(CompilerOptions.OPTION_ReportOverridingMethodWithoutSuperInvocation, severity, isEnabling); return; - } else if (token.equals("suppressAssertNull")) { //$NON-NLS-1$ - this.options.put( - CompilerOptions.OPTION_SuppressNullInfoFromAsserts, - isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED); - return; - } + } break; case 't' : if (token.startsWith("tasks")) { //$NON-NLS-1$ Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v retrieving revision 1.929 diff -u -r1.929 messages.properties --- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 28 Sep 2010 15:56:23 -0000 1.929 +++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 29 Sep 2010 12:09:51 -0000 @@ -288,6 +288,8 @@ \ hashCode missing hashCode() method when overriding equals()\n\ \ hiding macro for fieldHiding, localHiding, typeHiding and\n\ \ maskedCatchBlock\n\ +\ includeAssertNull raise null warnings for variables\n\ +\ that got tainted in an assert expression\n\ \ incomplete-switch same as enumSwitch\n\ \ indirectStatic indirect reference to static member\n\ \ intfAnnotation + annotation type used as super interface\n\ @@ -313,8 +315,7 @@ \ suppress + enable @SuppressWarnings\n\ \ When used with -err:, it can also silent optional\n\ \ errors and warnings\n\ -\ suppressAssertNull suppress null warnings for variables\n\ -\ that got tainted in an assert expression\n\ + \ syncOverride missing synchronized in synchr. method override\n\ \ syntheticAccess synthetic access for innerclass\n\ \ tasks() tasks identified by tags inside comments\n\ Index: compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java,v retrieving revision 1.64 diff -u -r1.64 AssertStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java 24 Sep 2010 06:30:57 -0000 1.64 +++ compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java 29 Sep 2010 12:09:51 -0000 @@ -84,9 +84,9 @@ // expression downstream } else { CompilerOptions compilerOptions = currentScope.compilerOptions(); - if (compilerOptions.suppressNullInfoFromAsserts) { + if (!compilerOptions.includeNullInfoFromAsserts) { // keep just the initializations info, don't include assert's null info - return flowInfo.mergedWith(assertInfo.nullInfoLessUnconditionalCopy()); + return flowInfo.addInitializationsFrom(assertInfo.nullInfoLessUnconditionalCopy()); } return flowInfo.mergedWith(assertInfo.nullInfoLessUnconditionalCopy()). addInitializationsFrom(assertWhenTrueInfo.discardInitializationInfo()); Index: compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java,v retrieving revision 1.69 diff -u -r1.69 UnconditionalFlowInfo.java --- compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 21 Sep 2010 06:32:55 -0000 1.69 +++ compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 29 Sep 2010 12:09:51 -0000 @@ -1466,6 +1466,7 @@ throw new AssertionFailedException("COVERAGE 28"); //$NON-NLS-1$ } } + combineNullStatusChangeInAssertInfo(otherInits); return this; } if ((this.tagBits & UNREACHABLE) != 0) { @@ -1474,6 +1475,7 @@ throw new AssertionFailedException("COVERAGE 29"); //$NON-NLS-1$ } } + otherInits.combineNullStatusChangeInAssertInfo(this); return (UnconditionalFlowInfo) otherInits.copy(); // make sure otherInits won't be affected } @@ -1761,6 +1763,7 @@ copy.potentialInits = this.potentialInits; copy.tagBits = this.tagBits & ~NULL_FLAG_MASK; copy.maxFieldCount = this.maxFieldCount; + copy.nullStatusChangedInAssert = this.nullStatusChangedInAssert; if (this.extra != null) { int length; copy.extra = new long[extraLength][]; Index: compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java,v retrieving revision 1.232 diff -u -r1.232 CompilerOptions.java --- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 24 Sep 2010 06:30:56 -0000 1.232 +++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 29 Sep 2010 12:09:51 -0000 @@ -131,7 +131,7 @@ public static final String OPTION_ReportDeadCodeInTrivialIfStatement = "org.eclipse.jdt.core.compiler.problem.deadCodeInTrivialIfStatement"; //$NON-NLS-1$ public static final String OPTION_ReportTasks = "org.eclipse.jdt.core.compiler.problem.tasks"; //$NON-NLS-1$ public static final String OPTION_ReportUnusedObjectAllocation = "org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation"; //$NON-NLS-1$ - public static final String OPTION_SuppressNullInfoFromAsserts = "org.eclipse.jdt.core.compiler.problem.suppressNullInfoFromAsserts"; //$NON-NLS-1$ + public static final String OPTION_IncludeNullInfoFromAsserts = "org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts"; //$NON-NLS-1$ // Backward compatibility public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$ public static final String OPTION_ReportMissingAnnotation = "org.eclipse.jdt.core.compiler.problem.missingAnnotation"; //$NON-NLS-1$ @@ -352,8 +352,8 @@ public boolean generateClassFiles; /** Indicate if method bodies should be ignored */ public boolean ignoreMethodBodies; - /** Suppress null related warnings for variables tainted inside an assert statement (java 1.5 and above)*/ - public boolean suppressNullInfoFromAsserts; + /** Raise null related warnings for variables tainted inside an assert statement (java 1.5 and above)*/ + public boolean includeNullInfoFromAsserts; // keep in sync with warningTokenToIrritant and warningTokenFromIrritant public final static String[] warningTokens = { @@ -916,7 +916,7 @@ optionsMap.put(OPTION_ReportDeadCodeInTrivialIfStatement, this.reportDeadCodeInTrivialIfStatement ? ENABLED : DISABLED); optionsMap.put(OPTION_ReportTasks, getSeverityString(Tasks)); optionsMap.put(OPTION_ReportUnusedObjectAllocation, getSeverityString(UnusedObjectAllocation)); - optionsMap.put(OPTION_SuppressNullInfoFromAsserts, this.suppressNullInfoFromAsserts ? ENABLED : DISABLED); + optionsMap.put(OPTION_IncludeNullInfoFromAsserts, this.includeNullInfoFromAsserts ? ENABLED : DISABLED); return optionsMap; } @@ -1063,7 +1063,7 @@ this.ignoreMethodBodies = false; // allow null info from asserts to be considered downstream by default - this.suppressNullInfoFromAsserts = false; + this.includeNullInfoFromAsserts = false; } public void set(Map optionsMap) { @@ -1270,11 +1270,11 @@ this.reportMissingOverrideAnnotationForInterfaceMethodImplementation = false; } } - if ((optionValue = optionsMap.get(OPTION_SuppressNullInfoFromAsserts)) != null) { + if ((optionValue = optionsMap.get(OPTION_IncludeNullInfoFromAsserts)) != null) { if (ENABLED.equals(optionValue)) { - this.suppressNullInfoFromAsserts = true; + this.includeNullInfoFromAsserts = true; } else if (DISABLED.equals(optionValue)) { - this.suppressNullInfoFromAsserts = false; + this.includeNullInfoFromAsserts = false; } } if ((optionValue = optionsMap.get(OPTION_ReportMethodWithConstructorName)) != null) updateSeverity(MethodWithConstructorName, optionValue); @@ -1519,7 +1519,7 @@ buf.append("\n\t- missing @Override annotation for interface method implementation: ").append(this.reportMissingOverrideAnnotationForInterfaceMethodImplementation ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- missing @Deprecated annotation: ").append(getSeverityString(MissingDeprecatedAnnotation)); //$NON-NLS-1$ buf.append("\n\t- incomplete enum switch: ").append(getSeverityString(IncompleteEnumSwitch)); //$NON-NLS-1$ - buf.append("\n\t- suppress null related warnings for variables tainted in assert statements: ").append(this.suppressNullInfoFromAsserts ? ENABLED : DISABLED); //$NON-NLS-1$ + buf.append("\n\t- raise null related warnings for variables tainted in assert statements: ").append(this.includeNullInfoFromAsserts ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- suppress warnings: ").append(this.suppressWarnings ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- suppress optional errors: ").append(this.suppressOptionalErrors ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- unhandled warning token: ").append(getSeverityString(UnhandledWarningToken)); //$NON-NLS-1$ Index: model/org/eclipse/jdt/core/JavaCore.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v retrieving revision 1.653 diff -u -r1.653 JavaCore.java --- model/org/eclipse/jdt/core/JavaCore.java 24 Sep 2010 06:30:56 -0000 1.653 +++ model/org/eclipse/jdt/core/JavaCore.java 29 Sep 2010 12:09:51 -0000 @@ -1427,20 +1427,20 @@ */ public static final String COMPILER_PB_SUPPRESS_WARNINGS = PLUGIN_ID + ".compiler.problem.suppressWarnings"; //$NON-NLS-1$ /** - * Compiler option ID: Suppress null related warnings arising because of assert statements. - *

When enabled, the compiler will not flag null warnings on variables that got marked as maybe or definitely - * null in an assert statement upstream.

- *

When disabled, the compiler will flag all null related warnings that have been enabled by the user, + * Compiler option ID: Raise null related errors or warnings arising because of assert statements. + *

When enabled, the compiler will flag all null related errors or warnings that have been enabled by the user, * irrespective of whether a variable occurred in an assert statement.

+ *

When disabled, the compiler will not flag null related errors or warnings on variables that got marked as maybe or definitely + * null in an assert statement upstream.

*
- *
Option id:
"org.eclipse.jdt.core.compiler.problem.suppressNullInfoFromAsserts"
+ *
Option id:
"org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts"
*
Possible values:
{ "enabled", "disabled" }
*
Default:
"disabled"
*
* @since 3.7 * @category CompilerOptionID */ - public static final String COMPILER_PB_SUPPRESS_NULL_INFO_ASSERTS = PLUGIN_ID + ".compiler.problem.suppressNullInfoFromAsserts"; //$NON-NLS-1$ + public static final String COMPILER_PB_INCLUDE_ASSERTS_IN_NULL_ANALYSIS = PLUGIN_ID + ".compiler.problem.includeNullInfoFromAsserts"; //$NON-NLS-1$ /** * Compiler option ID: Further Determining the Effect of @SuppressWarnings if also * {@link #COMPILER_PB_SUPPRESS_WARNINGS} is enabled. @@ -1488,7 +1488,9 @@ * Compiler option ID: Reporting Null Dereference. *

When enabled, the compiler will issue an error or a warning whenever a * variable that is statically known to hold a null value is used to - * access a field or method. + * access a field or method.

+ *

Assert statements are ignored unless {@link #COMPILER_PB_INCLUDE_ASSERTS_IN_NULL_ANALYSIS} + * is enabled.

*
*
Option id:
"org.eclipse.jdt.core.compiler.problem.nullReference"
*
Possible values:
{ "error", "warning", "ignore" }
@@ -1503,7 +1505,9 @@ *

When enabled, the compiler will issue an error or a warning whenever a * variable that has formerly been tested against null but is not (no more) * statically known to hold a non-null value is used to access a field or - * method. + * method.

+ *

Assert statements are ignored unless {@link #COMPILER_PB_INCLUDE_ASSERTS_IN_NULL_ANALYSIS} + * is enabled.

*
*
Option id:
"org.eclipse.jdt.core.compiler.problem.potentialNullReference"
*
Possible values:
{ "error", "warning", "ignore" }
@@ -1517,7 +1521,9 @@ * Compiler option ID: Reporting Redundant Null Check. *

When enabled, the compiler will issue an error or a warning whenever a * variable that is statically known to hold a null or a non-null value - * is tested against null. + * is tested against null.

+ *

Assert statements are ignored unless {@link #COMPILER_PB_INCLUDE_ASSERTS_IN_NULL_ANALYSIS} + * is enabled.

*
*
Option id:
"org.eclipse.jdt.core.compiler.problem.redundantNullCheck"
*
Possible values:
{ "error", "warning", "ignore" }
#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.211 diff -u -r1.211 BatchCompilerTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 24 Sep 2010 06:30:50 -0000 1.211 +++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 29 Sep 2010 12:09:57 -0000 @@ -1652,86 +1652,65 @@ "{0} {1}\n" + "{2}\n" + " \n" + - " Warning options:\n" + - " -deprecation + deprecation outside deprecated code\n" + - " -nowarn -warn:none disable all warnings\n" + - " -warn: enable exactly the listed warnings\n" + - " -warn:+ enable additional warnings\n" + - " -warn:- disable specific warnings\n" + - " allDeadCode dead code including trivial if(DEBUG) check\n" + - " allDeprecation deprecation including inside deprecated code\n" + - " allJavadoc invalid or missing javadoc\n" + - " allOver-ann all missing @Override annotations\n" + - " assertIdentifier + ''assert'' used as identifier\n" + - " boxing autoboxing conversion\n" + - " charConcat + char[] in String concat\n" + - " compareIdentical + comparing identical expressions\n" + - " conditionAssign possible accidental boolean assignment\n" + - " constructorName + method with constructor name\n" + - " deadCode + dead code excluding trivial if (DEBUG) check\n" + - " dep-ann missing @Deprecated annotation\n" + - " deprecation + deprecation outside deprecated code\n" + - " discouraged + use of types matching a discouraged access rule\n" + - " emptyBlock undocumented empty block\n" + + " Warning options:\n" + + " -deprecation + deprecation outside deprecated code\n" + + " -nowarn -warn:none disable all warnings\n" + + " -warn: enable exactly the listed warnings\n" + + " -warn:+ enable additional warnings\n" + + " -warn:- disable specific warnings\n" + + " allDeadCode dead code including trivial if(DEBUG) check\n" + + " allDeprecation deprecation including inside deprecated code\n" + + " allJavadoc invalid or missing javadoc\n" + + " allOver-ann all missing @Override annotations\n" + + " assertIdentifier + ''assert'' used as identifier\n" + + " boxing autoboxing conversion\n" + + " charConcat + char[] in String concat\n" + + " compareIdentical + comparing identical expressions\n" + + " conditionAssign possible accidental boolean assignment\n" + + " constructorName + method with constructor name\n" + + " deadCode + dead code excluding trivial if (DEBUG) check\n" + + " dep-ann missing @Deprecated annotation\n" + + " deprecation + deprecation outside deprecated code\n" + + " discouraged + use of types matching a discouraged access rule\n" + + " emptyBlock undocumented empty block\n" + " enumIdentifier ''enum'' used as identifier\n" + - " enumSwitch incomplete enum switch\n" + - " fallthrough possible fall-through case\n" + - " fieldHiding field hiding another variable\n" + - " finalBound type parameter with final bound\n" + - " finally + finally block not completing normally\n" + - " forbidden + use of types matching a forbidden access rule\n" + + " enumSwitch incomplete enum switch\n" + + " fallthrough possible fall-through case\n" + + " fieldHiding field hiding another variable\n" + + " finalBound type parameter with final bound\n" + + " finally + finally block not completing normally\n" + + " forbidden + use of types matching a forbidden access rule\n" + " hashCode missing hashCode() method when overriding equals()\n" + - " hiding macro for fieldHiding, localHiding, typeHiding and\n" + - " maskedCatchBlock\n" + - " incomplete-switch same as enumSwitch\n" + - " indirectStatic indirect reference to static member\n" + - " intfAnnotation + annotation type used as super interface\n" + - " intfNonInherited + interface non-inherited method compatibility\n" + + " hiding macro for fieldHiding, localHiding, typeHiding and\n" + + " maskedCatchBlock\n" + + " includeAssertNull raise null warnings for variables\n" + + " that got tainted in an assert expression\n" + + " incomplete-switch same as enumSwitch\n" + + " indirectStatic indirect reference to static member\n" + + " intfAnnotation + annotation type used as super interface\n" + + " intfNonInherited + interface non-inherited method compatibility\n" + " intfRedundant find redundant superinterfaces\n" + - " javadoc invalid javadoc\n" + - " localHiding local variable hiding another variable\n" + - " maskedCatchBlock + hidden catch block\n" + - " nls string literal lacking non-nls tag //$NON-NLS-$\n" + - " noEffectAssign + assignment without effect\n" + - " null potential missing or redundant null check\n" + - " nullDereference + missing null check\n" + - " over-ann missing @Override annotation (superclass)\n" + - " paramAssign assignment to a parameter\n" + - " pkgDefaultMethod + attempt to override package-default method\n" + - " raw + usage of raw type\n" + - " semicolon unnecessary semicolon, empty statement\n" + - " serial + missing serialVersionUID\n" + - " specialParamHiding constructor or setter parameter hiding a field\n" + - " static-access macro for indirectStatic and staticReceiver\n" + - " staticReceiver + non-static reference to static member\n" + - " super overriding a method without making a super invocation\n" + + " javadoc invalid javadoc\n" + + " localHiding local variable hiding another variable\n" + + " maskedCatchBlock + hidden catch block\n" + + " nls string literal lacking non-nls tag //$NON-NLS-$\n" + + " noEffectAssign + assignment without effect\n" + + " null potential missing or redundant null check\n" + + " nullDereference + missing null check\n" + + " over-ann missing @Override annotation (superclass)\n" + + " paramAssign assignment to a parameter\n" + + " pkgDefaultMethod + attempt to override package-default method\n" + + " raw + usage of raw type\n" + + " semicolon unnecessary semicolon, empty statement\n" + + " serial + missing serialVersionUID\n" + + " specialParamHiding constructor or setter parameter hiding a field\n" + + " static-access macro for indirectStatic and staticReceiver\n" + + " staticReceiver + non-static reference to static member\n" + + " super overriding a method without making a super invocation\n" + " suppress + enable @SuppressWarnings\n" + - " When used with -err:, it can also silent optional\n" + - " errors and warnings\n" + - " suppressAssertNull suppress null warnings for variables\n" + - " that got tainted in an assert expression\n" + - " syncOverride missing synchronized in synchr. method override\n" + - " syntheticAccess synthetic access for innerclass\n" + - " tasks() tasks identified by tags inside comments\n" + - " typeHiding + type parameter hiding another type\n" + - " unchecked + unchecked type operation\n" + - " unnecessaryElse unnecessary else clause\n" + - " unqualifiedField unqualified reference to field\n" + - " unused macro for unusedAllocation, unusedArgument,\n" + - " unusedImport, unusedLabel, unusedLocal,\n" + - " unusedPrivate, unusedThrown, and unusedTypeArgs\n" + - " unusedAllocation allocating an object that is not used\n" + - " unusedArgument unread method parameter\n" + - " unusedImport + unused import declaration\n" + - " unusedLabel + unused label\n" + - " unusedLocal + unread local variable\n" + - " unusedPrivate + unused private member declaration\n" + - " unusedThrown unused declared thrown exception\n" + - " unusedTypeArgs + unused type arguments for method\n" + - " uselessTypeCheck unnecessary cast/instanceof operation\n" + - " varargsCast + varargs argument need explicit cast\n" + - " warningToken + unsupported or unnecessary @SuppressWarnings\n" + - "\n"; + " When used with -err:, it can also silent optional\n" + + " errors and warnings\n" + + "\n"; String expandedExpectedOutput = MessageFormat.format(expectedOutput, new String[] { MAIN.bind("compiler.name"), @@ -1819,6 +1798,7 @@ "