How can I programmatically obtain the serialVersionUID for a class?

Tim Rohaly

The following piece of code shows you how to do this for the class java.lang.String:

    String s = new String("test");
    Class cl = s.getClass();
    long uid = ObjectStreamClass.lookup(cl).getSerialVersionUID();
The value of uid will be the same as the value printed out by serialver java.lang.String.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact