Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Bug/Problem: -XaddSerialVersionUID doesn't work with abstract classes

Hi.  I'm having some difficulty using the -XaddSerialVersionUID feature for abstract classes - it doesn't seem to work. 
 
The following is the test case:
 
First, what seems to work, then what doesn't.
 
I have a class B as follows:
----------------------------------------------------
import java.io.*;

public class B implements Serializable
{
    public void foo() throws Exception {
        FileOutputStream fos = new FileOutputStream("foo");
        fos.write(1);
        fos.write("foo".getBytes());
    }
}

--------------------------------------------------

When I get the serialVersionUID, I get something like -66037966...

Now, I have a aspect like the following:

-----------------------------------------------

import org.aspectj.lang.*;

import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;

aspect FileOutput
{
    pointcut writeByte(byte[] b):
        call(void (FileOutputStream||FileWriter).write(byte[])) && args(b);

    void around(byte[] b): writeByte(b)
    {
        byte[] result = fileOutput(b, thisJoinPoint.getSignature());
        proceed(result);
    }

    byte[] fileOutput(byte[] b, Signature sig)
    {
        return b;
    }
}

--------------------------------------------------

When I weave with -XaddSerialVersionUID, then I get the same serialVersionUID  -66037966...

So far, so good.

However, when I modify B.class to be abstract, then suddenly the "-XaddSerialVersionUID" doesn't give the same serialVerisonUID as the one before weaving.

B.class (abstract): 365003300....

B.class (abstract) with File.aj, with -XserialVersionUID: -66037966....

The funny thing is, the abstract class's weaved serialVersionUID is the same as weaved non-abstract class.

 

What's going on here?  How can I fix this problem?  I'm willing to fix aspectj sourcecode if needed if someone can point me where to change.

Thanks.


Back to the top