### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java,v retrieving revision 1.92 diff -u -r1.92 CompilationUnitDeclaration.java --- compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java 5 May 2011 14:29:58 -0000 1.92 +++ compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java 6 May 2011 13:18:44 -0000 @@ -215,7 +215,9 @@ CategorizedProblem[] problems = this.compilationResult.problems; int problemCount = this.compilationResult.problemCount; for (int i = 0; i < problemCount; i++) { - if (problems[i].getID() == IProblem.LocalVariableIsNeverUsed) { + CategorizedProblem currentProblem = problems[i]; + if (currentProblem.getID() == IProblem.LocalVariableIsNeverUsed + && currentProblem.isWarning()) { problems[i] = null; removed++; } @@ -299,7 +301,9 @@ if (remainingErrors > 0) { for (int i = 0; i < problemCount; i++) { CategorizedProblem problem; - if ((problem = problems[i]) != null && problem.getID() == IProblem.LocalVariableIsNeverUsed) { + if ((problem = problems[i]) != null + && problem.getID() == IProblem.LocalVariableIsNeverUsed + && problem.isWarning()) { problems[i] = null; removed++; } #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/LocalVariableTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LocalVariableTest.java,v retrieving revision 1.19 diff -u -r1.19 LocalVariableTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/LocalVariableTest.java 22 Oct 2010 22:42:32 -0000 1.19 +++ src/org/eclipse/jdt/core/tests/compiler/regression/LocalVariableTest.java 6 May 2011 13:18:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -714,6 +714,32 @@ // javac options JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=343621 +public void test021() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.ERROR); + runNegativeTest( + new String[] { /* test files */ + "X.java", + "public class X {\n" + + " public Object[] foo() {\n" + + " Object[] i, j= new Object[0];\n" + + " i= j = null;\n" + + " i= (new Object[] { null, null });\n" + + " return j;\n" + + " }\n" + + "}", // ================= + }, + "----------\n" + + "1. ERROR in X.java (at line 3)\n" + + " Object[] i, j= new Object[0];\n" + + " ^\n" + + "The value of the local variable i is not used\n" + + "----------\n", + null /* no class libraries */, + true, + options /* custom options */); +} public static Class testClass() { return LocalVariableTest.class; }