serialVersionUID mismatch using JDTCompilerAdapter [message #244310] |
Wed, 06 June 2007 17:24  |
Eclipse User |
|
|
|
Originally posted by: smendez_2000.yahoo.com
I am using Eclipse SDK 3.2.2. I am doing all compilation with JDK
1.4.2_08, but have seen this with JDK 1.5.0_12 as well.
I am getting a serialVerionsUID mismatch between the code that is compiled
using the Eclipse compiler, and the code that is compiled using my Ant
target.
I have properly setup the arguments for my Ant target to be
"-Dbuild.compiler=org.eclipse.jdt.core.JDTCompilerAdapter" so that the
Eclipse compiler is used when the javac task is called in Ant. The javac
is defined as follows in my build.xml file:
<javac destdir="${build.classes.dir}"
nowarn="on"
debug="on"
deprecation="off"
optimize="on"
source="1.2"
target="1.1"
classpathref="base.path"
fork="true"
memorymaximumsize="512m"
I am seeing a serialVersionUID mismatch between the anonymous inner
classes that are generated using the Eclipse compiler when I do a project
build, and the javac compiler through Ant (using the JDTCompilerAdapter.
I thought that the serialVersionUID should match as long as classes are
generated using the same compiler.
What is strange, is that the serialVersionUID DOES match up between the
main class (SingleAnonClass.class), and the inner class
(SingleAnonClass$AbstractCommand). I am only seeing serialVersionUID
mismatches between the anonymous inner classes (SingleAnonClass$1).
Am I missing something obvious? Any light anybody can shed on this would
be greatly appreciated it.
Thanks in advance,
Sergio
The serialVersionUIDs I am getting are:
com.sengent.clarifi.expression.basket.SingleAnonClass$1: static final
long serialVersionUID = -6854190831763635395L;
com.sengent.clarifi.expression.basket.SingleAnonClass$1: static final
long serialVersionUID = -6640405335798438680L;
The class I am using to test is as follows:
package com.sengent.clarifi.expression.basket;
import java.util.*;
/**
* Test
* @author Sergio Mendez
*
*/
public class SingleAnonClass implements java.io.Serializable
{
public SingleAnonClass()
{
}
/**
* Foo
*/
public List foo()
{
AbstractCommand bc = new AbstractCommand()
{
public void doExecute() throws Throwable
{
_returnValue = new ArrayList();
}
};
String errStr = "err msg";
bc.execute();
return (List) bc._returnValue;
}
/**
* Dummy Inner class
* @author Sergio Mendez
*
*/
private static abstract class AbstractCommand implements
java.io.Serializable
{
protected Throwable _throwable;
protected Object _returnValue;
protected abstract void doExecute() throws Throwable;
public void execute()
{
try
{
doExecute();
}
catch (Throwable t)
{
_throwable = t;
}
}
public boolean needsRollback()
{
// if we have a throwable, rollback
return _throwable != null;
}
}
}
|
|
|
|
|
|
|
|
Re: serialVersionUID mismatch using JDTCompilerAdapter [message #244444 is a reply to message #244427] |
Tue, 12 June 2007 12:14  |
Eclipse User |
|
|
|
Originally posted by: smendez_2000.yahoo.com
Olivier Thomann wrote:
> Sergio Mendez a écrit :
>> I am getting the following:
>>
>> com.Simpleton: static final long serialVersionUID =
>> -6405510230504268680L;
>> com.Simpleton: static final long serialVersionUID =
>> 1581926515960336856L;
>> Any thoughts?
> Are you absolutely sure that you are using the same compiler ?
> --
> Olivier
Yes. I actually figured out the problem. I had to adjust the JDK
Compliance settings in the project propeties, to be consistent with the
javac Ant target I was using. Once I did that, the serialVersionUID
mismatches went away.
Thanks for helping out with this.
Sergio
|
|
|
Powered by
FUDForum. Page generated in 0.03741 seconds