### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v retrieving revision 1.432 diff -u -r1.432 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 16 Feb 2011 07:56:50 -0000 1.432 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 27 Feb 2011 19:15:19 -0000 @@ -8,7 +8,9 @@ * Contributors: * IBM Corporation - initial API and implementation * Benjamin Muskalla - Contribution for bug 239066 - * Stephan Herrmann - Contribution for bug 236385 + * Stephan Herrmann - Contributions for + * bug 236385 - + * bug 338303 - Warning about Redundant assignment conflicts with definite assignment *******************************************************************************/ package org.eclipse.jdt.internal.compiler.problem; @@ -4981,6 +4983,8 @@ } public void localVariableRedundantNullAssignment(LocalVariableBinding local, ASTNode location) { + if ((location.bits & ASTNode.FirstAssignmentToLocal) != 0) // https://bugs.eclipse.org/338303 - Warning about Redundant assignment conflicts with definite assignment + return; int severity = computeSeverity(IProblem.RedundantLocalVariableNullAssignment); if (severity == ProblemSeverities.Ignore) return; String[] arguments = new String[] {new String(local.name) }; #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java,v retrieving revision 1.112 diff -u -r1.112 NullReferenceTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 16 Feb 2011 18:57:51 -0000 1.112 +++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 27 Feb 2011 19:15:39 -0000 @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Stephan Herrmann - Contributions for - * bugs 325755, 133125, 292478, 319201, 320170 and 332637 + * bugs 325755, 133125, 292478, 319201, 320170, 332637 and 338303 *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; @@ -14025,4 +14025,33 @@ }, ""); } +// https://bugs.eclipse.org/338303 - Warning about Redundant assignment conflicts with definite assignment +public void testBug338303() { + this.runConformTest( + new String[] { + "Bug338303.java", + "import java.io.File;\n" + + "import java.io.IOException;\n" + + "\n" + + "public class Bug338303 {\n" + + " Object test(Object in, final File f) {\n" + + " Object local;\n" + + " try {\n" + + " local = in;\n" + + " if (local == null)\n" + + " local = loadEntry(f, false);\n" + + " } catch (final IOException e) {\n" + + " e.printStackTrace();\n" + + " local = null;\n" + + " }\n" + + " return local;\n" + + " }\n" + + "\n" + + " private Object loadEntry(File f, boolean b) throws IOException {\n" + + " throw new IOException();\n" + + " }\n" + + "}\n" + }, + ""); +} } \ No newline at end of file