Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 192281 Details for
Bug 341475
Eclipse doesn't show a "never read locally" warning if a private field serialVersionUID exists but the class does not implement Serializable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + regression tests
patch_341475.txt (text/plain), 3.91 KB, created by
Olivier Thomann
on 2011-03-31 10:36:32 EDT
(
hide
)
Description:
Proposed fix + regression tests
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2011-03-31 10:36:32 EDT
Size:
3.91 KB
patch
obsolete
>### 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<T> {\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<T>.serialVersionUID is not used\n" + >+ "----------\n", >+ null, >+ true, >+ options >+ ); >+} > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 341475
: 192281