Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » serialVersionUID mismatch using JDTCompilerAdapter
serialVersionUID mismatch using JDTCompilerAdapter [message #244310] Wed, 06 June 2007 17:24 Go to next message
Eclipse UserFriend
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 #244337 is a reply to message #244310] Thu, 07 June 2007 11:36 Go to previous messageGo to next message
Eclipse UserFriend
Sergio Mendez a écrit :
> 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;
I tried and I got the same result in both cases:
D:\tests_sources\ANT>serialver
com.sengent.clarifi.expression.basket.SingleAnonClass$Abstra ctCommand
com.sengent.clarifi.expression.basket.SingleAnonClass$Abstra ctCommand:
static final long serialVersionUID = 4629955951312699982L;

D:\tests_sources\ANT>serialver
com.sengent.clarifi.expression.basket.SingleAnonClass
com.sengent.clarifi.expression.basket.SingleAnonClass: static final
long serialVersionUID = 7003982111737673916L;

D:\tests_sources\ANT>serialver
com.sengent.clarifi.expression.basket.SingleAnonClass$1
com.sengent.clarifi.expression.basket.SingleAnonClass$1: static final
long serialVersionUID = -6640405335798438680L;

D:\tests_sources\IDE\bin>serialver
com.sengent.clarifi.expression.basket.SingleAnonClass$1
com.sengent.clarifi.expression.basket.SingleAnonClass$1: static final
long serialVersionUID = -6640405335798438680L;

D:\tests_sources\IDE\bin>serialver
com.sengent.clarifi.expression.basket.SingleAnonClass
com.sengent.clarifi.expression.basket.SingleAnonClass: static final
long serialVersionUID = 7003982111737673916L;

D:\tests_sources\IDE\bin>serialver
com.sengent.clarifi.expression.basket.SingleAnonClass$Abstra ctCommand
com.sengent.clarifi.expression.basket.SingleAnonClass$Abstra ctCommand:
static final long serialVersionUID = 4629955951312699982L;

So I would need exact steps included your ant script in order to
investigate it further.
--
Olivier
Re: serialVersionUID mismatch using JDTCompilerAdapter [message #244342 is a reply to message #244337] Thu, 07 June 2007 12:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smendez_2000.yahoo.com

Olivier,

Here is the target that I use in my Ant Script

<target name="compile-code" depends="init">
<mkdir dir="${build.deploy.dir}"/>
<mkdir dir="${build.classes.dir}"/>
<javac destdir="${build.classes.dir}"
nowarn="on"
debug="on"
deprecation="off"
optimize="on"
source="1.2"
target="1.1"
excludes="com/sengent/clarifi/custom/**"
classpathref="base.path"
fork="true"
memorymaximumsize="512m"
>
<src path="${src.dir}"/>
<src path="${build.generate.dir}"/>
</javac>
<rmic base="${build.classes.dir}"
classpathref="base.path"
includes="com/sengent/clarifi/server/**/*Impl.class"/>
</target>

perhaps you can attach the target you used, and I can investigate in
prallel.

At least now I know that it works in somebodys setup :)

Sergio


Olivier Thomann wrote:

> Sergio Mendez a écrit :
>> 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;
> I tried and I got the same result in both cases:
> D:tests_sourcesANT>serialver
> com.sengent.clarifi.expression.basket.SingleAnonClass$Abstra ctCommand
> com.sengent.clarifi.expression.basket.SingleAnonClass$Abstra ctCommand:
> static final long serialVersionUID = 4629955951312699982L;

> D:tests_sourcesANT>serialver
> com.sengent.clarifi.expression.basket.SingleAnonClass
> com.sengent.clarifi.expression.basket.SingleAnonClass: static final
> long serialVersionUID = 7003982111737673916L;

> D:tests_sourcesANT>serialver
> com.sengent.clarifi.expression.basket.SingleAnonClass$1
> com.sengent.clarifi.expression.basket.SingleAnonClass$1: static final
> long serialVersionUID = -6640405335798438680L;

> D:tests_sourcesIDEbin>serialver
> com.sengent.clarifi.expression.basket.SingleAnonClass$1
> com.sengent.clarifi.expression.basket.SingleAnonClass$1: static final
> long serialVersionUID = -6640405335798438680L;

> D:tests_sourcesIDEbin>serialver
> com.sengent.clarifi.expression.basket.SingleAnonClass
> com.sengent.clarifi.expression.basket.SingleAnonClass: static final
> long serialVersionUID = 7003982111737673916L;

> D:tests_sourcesIDEbin>serialver
> com.sengent.clarifi.expression.basket.SingleAnonClass$Abstra ctCommand
> com.sengent.clarifi.expression.basket.SingleAnonClass$Abstra ctCommand:
> static final long serialVersionUID = 4629955951312699982L;

> So I would need exact steps included your ant script in order to
> investigate it further.
> --
> Olivier
Re: serialVersionUID mismatch using JDTCompilerAdapter [message #244354 is a reply to message #244342] Thu, 07 June 2007 21:38 Go to previous messageGo to next message
Eclipse UserFriend
Sergio Mendez a écrit :
> perhaps you can attach the target you used, and I can investigate in
> prallel.
>
> At least now I know that it works in somebodys setup :)
My target is very simple.
<?xml version="1.0" encoding="UTF-8"?>
<project name="compile" default="main" basedir="../.">
<property name="build.compiler"
value="org.eclipse.jdt.core.JDTCompilerAdapter" />
<property name="src" value="D:\tests_sources\com" />
<property name="out" value="D:\tests_sources\ANT" />
<target name="main">
<mkdir dir="${out}" />
<javac srcdir="${src}" destdir="${out}" debug="on" nowarn="true"
listfiles="true">
<!-- compilerarg compiler="org.eclipse.jdt.core.JDTCompilerAdapter"
line="-1.4" / -->
</javac>
</target>
</project>

And I run it in the same JRE than Eclipse. I tried with your target. I
got a warning that the "fork" setting is ignored because I am not using
the classic compiler.
Do you get the same warning?
If not, this would mean that you are not running the Eclipse compiler.
--
Olivier
Re: serialVersionUID mismatch using JDTCompilerAdapter [message #244384 is a reply to message #244354] Fri, 08 June 2007 11:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smendez_2000.yahoo.com

Olivier Thomann wrote:

> Sergio Mendez a écrit :
>> perhaps you can attach the target you used, and I can investigate in
>> prallel.
>>
>> At least now I know that it works in somebodys setup :)
> My target is very simple.
> <?xml version="1.0" encoding="UTF-8"?>
> <project name="compile" default="main" basedir="../.">
> <property name="build.compiler"
> value="org.eclipse.jdt.core.JDTCompilerAdapter" />
> <property name="src" value="D:tests_sourcescom" />
> <property name="out" value="D:tests_sourcesANT" />
> <target name="main">
> <mkdir dir="${out}" />
> <javac srcdir="${src}" destdir="${out}" debug="on" nowarn="true"
> listfiles="true">
> <!-- compilerarg compiler="org.eclipse.jdt.core.JDTCompilerAdapter"
> line="-1.4" / -->
> </javac>
> </target>
> </project>

> And I run it in the same JRE than Eclipse. I tried with your target. I
> got a warning that the "fork" setting is ignored because I am not using
> the classic compiler.
> Do you get the same warning?
> If not, this would mean that you are not running the Eclipse compiler.
> --
> Olivier


I did get that warning as well. I also found the source of the issue. It
seems I was using an older version of the ecj.jar. After I got the latest
version of it and rebuilt everything, the serialVersionUIDs matched up.

Unfortunately, I am now having a problem with a different class. The
following class (with interface) is now giving me serialVersionUID
mismatches:


package com;


/**
* Test
* @author Sergio Mendez
*
*/
public abstract class Simpleton implements SimpletonGroup
{

public Simpleton()
{
}

}


package com;



public interface SimpletonGroup extends java.io.Serializable
{

long foo();


}


I am getting the following:

com.Simpleton: static final long serialVersionUID =
-6405510230504268680L;
com.Simpleton: static final long serialVersionUID =
1581926515960336856L;


Any thoughts?

Sergio
Re: serialVersionUID mismatch using JDTCompilerAdapter [message #244427 is a reply to message #244384] Mon, 11 June 2007 22:48 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: serialVersionUID mismatch using JDTCompilerAdapter [message #244444 is a reply to message #244427] Tue, 12 June 2007 12:14 Go to previous message
Eclipse UserFriend
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
Previous Topic:Scub output folders when cleaning projects when projects outputs are in same location doesn't work
Next Topic:Eclipse can't find library files
Goto Forum:
  


Current Time: Sun Jun 08 19:40:35 EDT 2025

Powered by FUDForum. Page generated in 0.03741 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top