import utilities.files.*; public class Darwin { //------------------------------------------------------------------- // main() entry point //------------------------------------------------------------------- public static void main (String[] args) { Species test, ape; if ( args.length == 0 ) { System.out.println("Please specify SAVE or LOAD."); System.exit(10); } if ( args[0].equals("LOAD") ) { ape = (Species) FileKit.loadObject("ape.ser"); System.out.println("Loaded.. " + ape); } else if ( args[0].equals("SAVE") ) { ape = new Species("Bonobo", 7600); System.out.println("Saving.. " + ape); FileKit.saveObject(ape, "ape.ser"); } else { System.out.println("Valid arguments are SAVE or LOAD."); System.exit(10); } // now that the serialization/deserialization is done, see if we were // dealing with a BINARY COMPATIBLE class or not. test = new Species("Any", 0); boolean binaryCompatible = true; try { test.someMethod(1); } catch (NoSuchMethodError methodVanished) { System.out.println("Huh? A method vanished from class Species!"); binaryCompatible = false; } String toBeOrNotToBe = binaryCompatible ? "was" : "was not"; System.out.println("Class Species " + toBeOrNotToBe + " binary compatible."); } } // End of Class Darwin