• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • Byte Code Transform
  • kkannaiy
  • Reporter: ag_rocks
  • September 09, 2009
  • 0
  • Watchers: 1
  • February 12, 2013
  • November 23, 2009



static final anonymous serializable classes are not stamped with correct serialVersionUID when instrumented with Terracotta. If you serialize an object of a class which is intrumented, and then try to deserialize it on a JVM without terracotta, it results in InvalidClassException, complaining about a mismatch of serialVersionUID.

Attached is a simple test to reproduce this problem. It has no roots, but just instrumentation of class DataTypes and DataTypes$1.

Steps to reproduce.

  1. Run SerializationTest.java with Terracotta using the tc-config.xml provided. This will produce a serialied object of type DataType.TEST.

  2. Run Reader without terracotta and it will result in InvalidClassException.

Note : This problem somehow happens only on RHEL and Solaris Boxes and is not produceable on Windows.

JDK used is 1.6 update 14.


Tim Eck 2009-09-09

I think this is a bug in ASM actually (which Terracotta uses, so it is still a Terracotta bug too of course). I’ll see if I can dig up the underlying ASM issue. Might be as simple as upgrading ASM internally

Tim Eck 2009-09-09

Potentially is this: http://svn.forge.objectweb.org/cgi-bin/viewcvs.cgi/asm/trunk/asm/src/org/objectweb/asm/commons/SerialVersionUIDAdder.java?rev=1377&r1=1272&r2=1377

A G 2009-09-09

I will try out with this patch on com.tc.asm.commons.SerialVersionhUIDAdder.visitInnerClass() method, and report if the problem goes away.

However, can you help me understand why we see it on solaris or RHEL and not Windows box.

Tim Eck 2009-09-09

I appreciate you trying out that patch! I don’t know for sure if that is the problem you’re experiencing but it sounds pretty close.

A G 2009-09-11

I tried it out. This didn’nt work. The only option left is to stamp serialVersionUIDs manually in all such classes, which is kind of not ethical i guess.

Alex Miller 2009-11-16


Chris Dennis 2009-11-18

The sample works perfectly on my Mac OSX machine, but fails on dev05 (a RHEL machine). The failure persists in the latest trunk, which now uses ASM 3.2 - so something very odd is going on here.

I’ll poke around this a little more….

Tim Eck 2009-11-18

sure sounds like the input class is different for some reason in those cases. I can’t believe that [given the same input] you’d see a difference in ASM that is dependent on OS.

Chris Dennis 2009-11-18

Further investigation has led me to the conclusion that this is an ASM bug. I haven’t been able to pin down exactly what ASM is doing wrong, but the attached test case shows the errant behavior. If you run the bash script inside the zip passing it a java home to use (./suid_test.sh ${JAVA_HOME}), it runs the failing class (which i’ve reduced to a minimal test case) through the SerialVersionUIDAdder in isolation (no TC code involved). It then runs the installed JRE’s serialver command against the same class.

On all the machines I have tried this with so far 1.4 and 1.5 JVMs produce identical serialVersionUID values, but all 1.6 JVMs fail. Interestingly the JVM reports the same UID for all Java versions, but ASM fails to generate the correct one when fed the 1.6 compiled class.

Chris Dennis 2009-11-19

ASM bug filed:


Chris Dennis 2009-11-19

I’ve now tracked down the bug in ASM, and have attached a patch to the ASM issue that I filed. Once it gets approval from the ASM guys I will apply the patch to the TC repackaged ASM. Assuming a timely response from the ASM developers this should be fixed in the next major release.

Chris Dennis 2009-11-23

My patch was merged into the ASM repo over the weekend, so I’ve patched our local copy in the same way to fix this issue.

Kalai Kannaiyan 2009-12-08

Reproduced with 3.0.1 [Terracotta 3.0.1, as of 20090514-130552 (Revision 12704 by [email protected] from 3.0)]. Verified the fix with 3.2, it is working fine as expected.


  1. Unzip the attached project.zip and compile the project
  2. start the TC server -> bin/start-tc-server.sh -f ../project/tc-config.xml
  3. Run the Serialization with Terracotta
  4. execute bin/dso-java.sh -cp classes com.terracottatest.SerializationTest from project

Actual: File created successfully Starting Terracotta client… 2009-12-08 12:48:39,828 INFO - Terracotta 3.0.1, as of 20090514-130552 (Revision 12704 by [email protected] from 3.0) 2009-12-08 12:48:40,421 INFO - Configuration loaded from the file at ‘c:\Program Files\Terracotta\terracotta-3.0.1\project\tc-config.xml’. 2009-12-08 12:48:40,671 INFO - Log file: ‘c:\Program Files\Terracotta\terracotta -3.0.1\project\target\terracotta-data\logs\client-logs\terracotta-client.log’. 2009-12-08 12:48:43,734 INFO - Connection successfully established to server at Creating File/Object output stream… Writing DataTypes.Enum Object… Closing all output streams…

  1. stop the TC server
  2. Run the Reader without Terracotta
  3. execute java -cp classes com.terracottatest.Reader

Actual: Exception in thread “main” java.io.InvalidClassException: com.terracottatest.Dat aTypes$1; local class incompatible: stream classdesc serialVersionUID = -2441598 732770902725, local class serialVersionUID = 1462347316826359722 at java.io.ObjectStreamClass.initNonProxy(Unknown Source) at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source) at java.io.ObjectInputStream.readClassDesc(Unknown Source) at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at java.io.ObjectInputStream.readObject0(Unknown Source) at java.io.ObjectInputStream.readObject(Unknown Source) at com.terracottatest.Reader.main(Reader.java:16)

  1. Verify the fix with 3.2
  2. Repeat the steps 1 to 4

Actual: File created successfully Starting Terracotta client… 2009-12-08 13:17:01,531 INFO - Terracotta 3.2.0-nightly, as of 20091208-081234 ( Revision 14155 by [email protected] from 3.2) 2009-12-08 13:17:02,140 INFO - Configuration loaded from the file at ‘c:\Program Files\Terracotta\terracotta-3.2.0-nightly-rev14155\project\tc-config.xml’. 2009-12-08 13:17:02,375 INFO - Log file: ‘c:\Program Files\Terracotta\terracotta -3.2.0-nightly-rev14155\project\target\terracotta-data\logs\client-logs\terracot ta-client.log’. 2009-12-08 13:17:04,656 INFO - Connection successfully established to server at Creating File/Object output stream… Writing DataTypes.Enum Object… Closing all output streams…

  1. Repeat 5 to 7

Actual: [email protected]