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 78311 Details for
Bug 203241
[compiler] Missing warning when a serializable class without serialVersionUID is also abstract
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + updated regression tests
patch_203241.txt (text/plain), 8.07 KB, created by
Olivier Thomann
on 2007-09-13 10:30:48 EDT
(
hide
)
Description:
Proposed fix + updated regression tests
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2007-09-13 10:30:48 EDT
Size:
8.07 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java,v >retrieving revision 1.137 >diff -u -r1.137 TypeDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java 25 Apr 2007 16:59:23 -0000 1.137 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java 13 Sep 2007 14:29:21 -0000 >@@ -938,51 +938,50 @@ > } > boolean needSerialVersion = > this.scope.compilerOptions().getSeverity(CompilerOptions.MissingSerialVersion) != ProblemSeverities.Ignore >- && sourceType.isClass() >- && !sourceType.isAbstract() >+ && sourceType.isClass() > && sourceType.findSuperTypeErasingTo(TypeIds.T_JavaIoExternalizable, false /*Serializable is not a class*/) == null > && sourceType.findSuperTypeErasingTo(TypeIds.T_JavaIoSerializable, false /*Serializable is not a class*/) != null; > > if (needSerialVersion) { > // if Object writeReplace() throws java.io.ObjectStreamException is present, then no serialVersionUID is needed > // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=101476 >- CompilationUnitScope compilationUnitScope = this.scope.compilationUnitScope(); >+ CompilationUnitScope compilationUnitScope = this.scope.compilationUnitScope(); > MethodBinding methodBinding = sourceType.getExactMethod(TypeConstants.WRITEREPLACE, new TypeBinding[0], compilationUnitScope); >- ReferenceBinding[] throwsExceptions; >+ ReferenceBinding[] throwsExceptions; > needSerialVersion = > methodBinding == null >- || !methodBinding.isValidBinding() >- || methodBinding.returnType.id != TypeIds.T_JavaLangObject >- || (throwsExceptions = methodBinding.thrownExceptions).length != 1 >- || throwsExceptions[0].id != TypeIds.T_JavaIoObjectStreamException; >- if (needSerialVersion) { >- // check the presence of an implementation of the methods >- // private void writeObject(java.io.ObjectOutputStream out) throws IOException >- // private void readObject(java.io.ObjectInputStream out) throws IOException >- boolean hasWriteObjectMethod = false; >- boolean hasReadObjectMethod = false; >- TypeBinding argumentTypeBinding = this.scope.getType(TypeConstants.JAVA_IO_OBJECTOUTPUTSTREAM, 3); >- if (argumentTypeBinding.isValidBinding()) { >- methodBinding = sourceType.getExactMethod(TypeConstants.WRITEOBJECT, new TypeBinding[] { argumentTypeBinding }, compilationUnitScope); >- hasWriteObjectMethod = methodBinding != null >- && methodBinding.isValidBinding() >- && methodBinding.modifiers == ClassFileConstants.AccPrivate >- && methodBinding.returnType == TypeBinding.VOID >- && (throwsExceptions = methodBinding.thrownExceptions).length == 1 >- && throwsExceptions[0].id == TypeIds.T_JavaIoException; >- } >- argumentTypeBinding = this.scope.getType(TypeConstants.JAVA_IO_OBJECTINPUTSTREAM, 3); >- if (argumentTypeBinding.isValidBinding()) { >- methodBinding = sourceType.getExactMethod(TypeConstants.READOBJECT, new TypeBinding[] { argumentTypeBinding }, compilationUnitScope); >- hasReadObjectMethod = methodBinding != null >- && methodBinding.isValidBinding() >- && methodBinding.modifiers == ClassFileConstants.AccPrivate >- && methodBinding.returnType == TypeBinding.VOID >- && (throwsExceptions = methodBinding.thrownExceptions).length == 1 >- && throwsExceptions[0].id == TypeIds.T_JavaIoException; >- } >- needSerialVersion = !hasWriteObjectMethod || !hasReadObjectMethod; >- } >+ || !methodBinding.isValidBinding() >+ || methodBinding.returnType.id != TypeIds.T_JavaLangObject >+ || (throwsExceptions = methodBinding.thrownExceptions).length != 1 >+ || throwsExceptions[0].id != TypeIds.T_JavaIoObjectStreamException; >+ if (needSerialVersion) { >+ // check the presence of an implementation of the methods >+ // private void writeObject(java.io.ObjectOutputStream out) throws IOException >+ // private void readObject(java.io.ObjectInputStream out) throws IOException >+ boolean hasWriteObjectMethod = false; >+ boolean hasReadObjectMethod = false; >+ TypeBinding argumentTypeBinding = this.scope.getType(TypeConstants.JAVA_IO_OBJECTOUTPUTSTREAM, 3); >+ if (argumentTypeBinding.isValidBinding()) { >+ methodBinding = sourceType.getExactMethod(TypeConstants.WRITEOBJECT, new TypeBinding[] { argumentTypeBinding }, compilationUnitScope); >+ hasWriteObjectMethod = methodBinding != null >+ && methodBinding.isValidBinding() >+ && methodBinding.modifiers == ClassFileConstants.AccPrivate >+ && methodBinding.returnType == TypeBinding.VOID >+ && (throwsExceptions = methodBinding.thrownExceptions).length == 1 >+ && throwsExceptions[0].id == TypeIds.T_JavaIoException; >+ } >+ argumentTypeBinding = this.scope.getType(TypeConstants.JAVA_IO_OBJECTINPUTSTREAM, 3); >+ if (argumentTypeBinding.isValidBinding()) { >+ methodBinding = sourceType.getExactMethod(TypeConstants.READOBJECT, new TypeBinding[] { argumentTypeBinding }, compilationUnitScope); >+ hasReadObjectMethod = methodBinding != null >+ && methodBinding.isValidBinding() >+ && methodBinding.modifiers == ClassFileConstants.AccPrivate >+ && methodBinding.returnType == TypeBinding.VOID >+ && (throwsExceptions = methodBinding.thrownExceptions).length == 1 >+ && throwsExceptions[0].id == TypeIds.T_JavaIoException; >+ } >+ needSerialVersion = !hasWriteObjectMethod || !hasReadObjectMethod; >+ } > } > // generics (and non static generic members) cannot extend Throwable > if (sourceType.findSuperTypeErasingTo(TypeIds.T_JavaLangThrowable, true) != null) { >@@ -990,13 +989,13 @@ > checkEnclosedInGeneric : do { > if (current.isGenericType()) { > this.scope.problemReporter().genericTypeCannotExtendThrowable(this); >- break checkEnclosedInGeneric; >+ break checkEnclosedInGeneric; > } > if (current.isStatic()) break checkEnclosedInGeneric; > if (current.isLocalType()) { > NestedTypeBinding nestedType = (NestedTypeBinding) current.erasure(); > if (nestedType.scope.methodScope().isStatic) break checkEnclosedInGeneric; >- } >+ } > } while ((current = current.enclosingType()) != null); > } > this.maxFieldCount = 0; >#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.2 >diff -u -r1.2 SerialVersionUIDTests.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/SerialVersionUIDTests.java 13 Sep 2007 11:27:28 -0000 1.2 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/SerialVersionUIDTests.java 13 Sep 2007 14:29:24 -0000 >@@ -136,6 +136,8 @@ > ); > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=203241 >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=116733 >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=94352 > public void test007() { > this.runNegativeTest( > new String[] { >@@ -144,7 +146,12 @@ > "public class X extends A {}\n" > }, > "----------\n" + >- "1. ERROR in X.java (at line 2)\n" + >+ "1. ERROR in X.java (at line 1)\n" + >+ " abstract class A implements java.io.Serializable {}\n" + >+ " ^\n" + >+ "The serializable class A does not declare a static final serialVersionUID field of type long\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 2)\n" + > " public class X extends A {}\n" + > " ^\n" + > "The serializable class X does not declare a static final serialVersionUID field of type long\n" +
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 203241
:
78311
|
78341