Project: JDT
Bug 139381 [clean up] CE when adding generated serial version ID
Reported: 2006-04-29 04:48:00 | Status: verified fixed

I get the following exception stacktrace when cleaning up a very special combination of inner classes which I reduced to a small demo class: === Stacktrace ================================================================ java.lang.reflect.InvocationTargetException at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:91) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113) Caused by: org.eclipse.core.runtime.CoreException: The class Demo$2 does not implement 'java.io.Serializable' or 'java.io.Externalizable' or has already an id at org.eclipse.jdt.internal.ui.text.correction.SerialVersionComputationHelper.computeSerialIDs(SerialVersionComputationHelper.java:99) at org.eclipse.jdt.internal.ui.text.correction.SerialVersionHashOperation.calculateSerialVersionIds(SerialVersionHashOperation.java:99) at org.eclipse.jdt.internal.corext.fix.PotentialProgrammingProblemsFix$SerialVersionHashContext.initialize(PotentialProgrammingProblemsFix.java:89) at org.eclipse.jdt.internal.corext.fix.PotentialProgrammingProblemsFix.createSerialVersionHashContext(PotentialProgrammingProblemsFix.java:249) at org.eclipse.jdt.internal.ui.fix.PotentialProgrammingProblemsCleanUp.beginCleanUp(PotentialProgrammingProblemsCleanUp.java:179) at org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.initCleanUps(CleanUpRefactoring.java:466) at org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.cleanUpProject(CleanUpRefactoring.java:431) at org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.checkFinalConditions(CleanUpRefactoring.java:399) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:83) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:118) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1737) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87) ... 1 more Root exception: org.eclipse.core.runtime.CoreException: The class Demo$2 does not implement 'java.io.Serializable' or 'java.io.Externalizable' or has already an id at org.eclipse.jdt.internal.ui.text.correction.SerialVersionComputationHelper.computeSerialIDs(SerialVersionComputationHelper.java:99) at org.eclipse.jdt.internal.ui.text.correction.SerialVersionHashOperation.calculateSerialVersionIds(SerialVersionHashOperation.java:99) at org.eclipse.jdt.internal.corext.fix.PotentialProgrammingProblemsFix$SerialVersionHashContext.initialize(PotentialProgrammingProblemsFix.java:89) at org.eclipse.jdt.internal.corext.fix.PotentialProgrammingProblemsFix.createSerialVersionHashContext(PotentialProgrammingProblemsFix.java:249) at org.eclipse.jdt.internal.ui.fix.PotentialProgrammingProblemsCleanUp.beginCleanUp(PotentialProgrammingProblemsCleanUp.java:179) at org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.initCleanUps(CleanUpRefactoring.java:466) at org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.cleanUpProject(CleanUpRefactoring.java:431) at org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring.checkFinalConditions(CleanUpRefactoring.java:399) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:83) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:118) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1737) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113) === Sourcecode ================================================================ import java.io.Serializable; public class Demo { void method1() { new Serializable() {}; } void method2() { new Object() {}; // Demo$2 when compiled new Serializable() {}; } } I did this with a fresh unzipped version of 3.2RC2 (I recognized the error first in RC1) and a fresh workspace, VM is 1.5_06. Applying the clean up... wizard with its default settings expect Missing Code->Add serial version ID->Generated checked (Default(1L) does do the (bug)job). Subsequent calls to the wizard presents the same bug even if it is applied to a class which should work. Only a restart makes the wizard forget the error. I think "Demo$2" refers to the subclass of Object which actually does not implement Serializable or Externalizable. Note that the order of the inner classes is important as is the fact that one Serializable class is in another method. Defining all three inner classes in one method does not reproduce the bug.

Files changed in fix:
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/CleanUpTest.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/AbstractSerialVersionOperation.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/PotentialProgrammingProblemsFix.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/SerialVersionDefaultOperation.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SerialVersionHashOperation.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SerialVersionLaunchConfigurationDelegate.java