Main method. Where it all begins... and ends too.
int lineNumber = 0;
ClassFile classfile;
FileReference file = FileReference.create(args[0], args[1]);
//declare a ClassParser object
//create a new ClassFile object passing it the name of the
//class file
classfile = new ClassFile (file, args[1], (byte)'L");
//read the class file
try {
classfile.readClassFile ();
} catch (IOException e) {
Log.LOGN(3, "Main: caught IOException " + e);
}
Log.LOGN(3, "\n");
//if a line number was not specified then just output everything
if (args.length < 3)
classfile.print (System.out);
else {
//just output the information for the method the specified by line number
lineNumber = Integer.parseInt (args[2]);
MethodInfo method = classfile.lookUpMethodByLineNumber (lineNumber);
if (method != null)
{
Log.LOGN(3, "Associated the method \"" + method.getName () +
"\" with line number " + lineNumber + ".");
Log.LOGN(3, "The following information if available for " +
method.getName () + ".");
Log.LOGN(3, method.toString());
//output the code array index for this method at which a breakpoint
//should be placed in order to stop at the specified line in the
//source file.
Log.LOGN(3, "");
Log.LOGN(3, "To put a breakpoint at line " + lineNumber +
" break at code index " +
method.getCodeIndex (lineNumber) + ".");
Log.LOGN(3, "");
Log.LOGN(3, "Breakpoints can be set at the following lines in " +
method.getName () + ":");
Log.LOGN(3, "tSource Line Number\tBytecode Offset");
Log.LOGN(3, "t------------------\t---------------");
int lineNumbers[][] = method.getBreakableLineNumbers ();
if (lineNumbers == null)
Log.LOGN(3, "Method contains no breakable lines.");
else
for (int lcv = 0; lcv < lineNumbers.length; ++lcv)
Log.LOGN(3, "t\t" + lineNumbers[lcv][0] + "\t\t\t" + lineNumbers[lcv][1]);
}
else
//the specified line was not an executable line of code within a method
Log.LOGN(3, "Line number " + lineNumber + " does not contain" +
" code within a method.");
}
// classfile.getVariableTableForMethodName("main");