public void parseFile(String _argument) {
Class argClass = null;
String serializedClassName = null;
foundExternalizable = false;
foundSerializable = false;
serializedClassName = new String(_argument + ".ser");
// In any case we need to load the argument classes, do this
// using reflection.
try
{
// Load the class using this class' classloader, and initialize it using the
// public no-args constructor.
output.append("[" + _argument + "] ");
argClass =
Class.forName(
_argument,
true,
CompatibilityToolParser.class.getClassLoader());
// Verify that the class implements the Externalizable interface. This
// is a requirement so that we can persist (write to disk) an instance
// of the class, and be able to read it back from a serialized state into
// an instance.
findInterfaces(argClass.getInterfaces());
if (!(foundExternalizable || foundSerializable))
{
// A contract class didn't implement java.io.Externalizable or java.io.Serializable,
// which is a requirement, so exit.
output.append(
"- > Contract class does not implement Externalizable or Serializable!\n");
result = -1;
} else
{
// The contract class correctly implemented java.io.Externalizable or
// java.io.Serializable.
output.append(
foundExternalizable
? "- > Externalizable, "
: "- > Serializable, ");
// See what it is we were called to do (make or check)
if (command.equalsIgnoreCase("make"))
{
serializeAndWriteFile(serializedClassName, argClass);
}
// check existing serialized file
else
{
checkSerializedFile(serializedClassName);
}
}
} catch (ClassNotFoundException e)
{
// Class isn't in classpath, give a meaningful response.
output.append("- > Contract class not in classpath!\n");
result = -1;
} catch (Throwable e)
{
output.append(
"- > Could not load class, dependent classes may not be in classpath.\n");
result = -1;
}
}
|