FileDocCategorySizeDatePackage
GetSerVersUID.javaAPI DocExample986Sun Feb 08 21:33:54 GMT 2004None

GetSerVersUID

public class GetSerVersUID extends Object
This program shows how to use getSerialVersionUID for a class that isn't in a package and thus not findable to the normal "serialver" tool.
author
Ian Darwin, http://www.darwinsys.com/

Fields Summary
static final String
ident
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] av)

	       

		// First we construct a Class object for the given class
		Class cl = Class.forName("Candidate");

		// Then an ObjectStreamClass for the given class
		ObjectStreamClass ocl = ObjectStreamClass.lookup(cl);

		// And use the ObjectStreamClass to get the Class'
		// unique SerialVersionUID
		System.out.println("For class " + cl);
		System.out.println("static final long serialVersionUID = " +
			ocl.getSerialVersionUID() + "L;"); // must be long

		// And just for reference...
		System.out.println("(Must range from " + Long.MIN_VALUE +
			" to " + Long.MAX_VALUE + ".)");