/** * reads or creates the serialVersionUID for the given class. * * @param classname the class to get the serialVersionUID for * @return the UID, 0L for non-serializable classes (or if the class cannot be * loaded) */ public static long getUID(String classname) { long result; try { // result = getUID(Class.forName(classname)); result = getUID(WekaPackageClassLoaderManager.forName(classname)); } catch (Exception e) { result = 0L; } return result; }
/** * reads or creates the serialVersionUID for the given class. * * @param classname the class to get the serialVersionUID for * @return the UID, 0L for non-serializable classes (or if the class cannot be * loaded) */ public static long getUID(String classname) { long result; try { // result = getUID(Class.forName(classname)); result = getUID(WekaPackageClassLoaderManager.forName(classname)); } catch (Exception e) { result = 0L; } return result; }
/** * Outputs information about a class on the commandline, takes class name as * arguments. * * @param args the classnames to check * @throws Exception if something goes wrong */ public static void main(String[] args) throws Exception { if (args.length == 0) { System.out.println("\nUsage: " + SerializationHelper.class.getName() + " classname [classname [classname [...]]]\n"); System.exit(1); } // check all the classes System.out.println(); for (String arg : args) { System.out.println(arg); System.out.println("- is serializable: " + isSerializable(arg)); System.out.println("- has " + SERIAL_VERSION_UID + ": " + hasUID(arg)); System.out .println("- needs " + SERIAL_VERSION_UID + ": " + needsUID(arg)); System.out.println("- " + SERIAL_VERSION_UID + ": private static final long serialVersionUID = " + getUID(arg) + "L;"); System.out.println(); } } }
/** * Outputs information about a class on the commandline, takes class name as * arguments. * * @param args the classnames to check * @throws Exception if something goes wrong */ public static void main(String[] args) throws Exception { if (args.length == 0) { System.out.println("\nUsage: " + SerializationHelper.class.getName() + " classname [classname [classname [...]]]\n"); System.exit(1); } // check all the classes System.out.println(); for (String arg : args) { System.out.println(arg); System.out.println("- is serializable: " + isSerializable(arg)); System.out.println("- has " + SERIAL_VERSION_UID + ": " + hasUID(arg)); System.out .println("- needs " + SERIAL_VERSION_UID + ": " + needsUID(arg)); System.out.println("- " + SERIAL_VERSION_UID + ": private static final long serialVersionUID = " + getUID(arg) + "L;"); System.out.println(); } } }