### 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.434 diff -u -r1.434 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 28 Feb 2011 18:27:48 -0000 1.434 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 31 Mar 2011 14:36:54 -0000 @@ -7328,7 +7328,12 @@ && field.isStatic() && field.isFinal() && TypeBinding.LONG == field.type) { - return; // do not report unused serialVersionUID field + ReferenceBinding referenceBinding = field.declaringClass; + if (referenceBinding != null) { + if (referenceBinding.findSuperTypeOriginatingFrom(TypeIds.T_JavaIoSerializable, false /*Serializable is not a class*/) != null) { + return; // do not report unused serialVersionUID field for class that implements Serializable + } + } } if (CharOperation.equals(TypeConstants.SERIALPERSISTENTFIELDS, field.name) && field.isStatic() #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/SerialVersionUIDTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SerialVersionUIDTests.java,v retrieving revision 1.8 diff -u -r1.8 SerialVersionUIDTests.java --- src/org/eclipse/jdt/core/tests/compiler/regression/SerialVersionUIDTests.java 1 Oct 2009 19:26:00 -0000 1.8 +++ src/org/eclipse/jdt/core/tests/compiler/regression/SerialVersionUIDTests.java 31 Mar 2011 14:36:55 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. + * Copyright (c) 2006, 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 @@ -16,6 +16,8 @@ import java.util.Map; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import junit.framework.Test; @@ -207,4 +209,49 @@ "" ); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=341475 +public void test011() { + Map options = getCompilerOptions(); + options.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.ERROR); + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " private static final long serialVersionUID = 1L;\n" + + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " private static final long serialVersionUID = 1L;\n" + + " ^^^^^^^^^^^^^^^^\n" + + "The value of the field X.serialVersionUID is not used\n" + + "----------\n", + null, + true, + options + ); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=341475 +public void test012() { + if (this.complianceLevel < ClassFileConstants.JDK1_5) return; + Map options = getCompilerOptions(); + options.put(JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER, JavaCore.ERROR); + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " private static final long serialVersionUID = 1L;\n" + + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " private static final long serialVersionUID = 1L;\n" + + " ^^^^^^^^^^^^^^^^\n" + + "The value of the field X.serialVersionUID is not used\n" + + "----------\n", + null, + true, + options + ); +} }