|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.tools.xref.xref
This class scans a compiled Java codebase and produces a set of HTML files containing 'where used' information about the codebase. TO DO: 1) unused/uncalled methods foreach package 2) unused/uncalled fields foreach package 3) unused/uncalled constants foreach package CLEANUP TODO: 1) Eliminate redundant code, adding new PackageSpec, ClassInterfaceSpec, MethodSpec & FieldSpec's to the master SpecContainer. 2) Redundant code in processCode() in this file.
Known Problems: 1. References to some static final variables are not found at this time. The javac compiler compiles this information in such as way that it is not clear from the bytecode, what is being referenced in a comparison statement. Consider the following: public static final int SUCCESS = 0; void someMethod(int value) { if ( value == SUCCESS ) return } In non-static final variables, the compiler emit's getfield and/or putfield instructions for references to fields and in the disassembled output you see the name of the field. With public static final fields, it does not emit getfield/putfield instructions.
Field Summary | |
(package private) String |
d_currentClassInterfaceName
This variable stores the name of the current Class/Interface being processed. |
(package private) ClassInterfaceSpec |
d_currentClassInterfaceSpec
This variable stores a reference to the current ClassInterface object that is being processed. |
(package private) Spec |
d_currentPackageSpec
This variable stores the name of the current package being processed. |
(package private) boolean |
d_firstTimeCalled
This variable is used to make sure that d_topLevelPackageName gets initialized only one time. |
(package private) String |
d_outputDirectory
This variable stores the name of the output directory that the user passed in on the command line. |
(package private) String |
d_rootPackageName
This variable stores the name of the root package name that the user passed in on the command line. |
(package private) String |
d_startingDirectory
This variable stores the name of the starting directory that the user passed in on the command line. |
(package private) String |
d_topLevelPackageName
This variable stores the top level prefix of the codebase being scanned by this tool. |
static String |
DEFAULT_ROOT_PACKAGE_NAME
|
Constructor Summary | |
xref()
Constructor |
Method Summary | |
(package private) void |
addClass(String classSpec)
This convenience method extracts the packageName and className from the specified classSpec and then add's them both to the codebaseXref container. |
(package private) void |
directoryCheck(String dirName)
|
boolean |
directoryNameOk(String directoryName)
This method implements the ProcessFileInterface |
(package private) void |
exceptionCheck(ClassInterfaceSpec cis)
|
boolean |
fileTypeOk(String fileName)
This method provides filename filtering capability to this application and in the case of this application, all we want to do is process .class files, so this method only returns true if the fileName is a .class file. |
(package private) void |
getParentInterfaces(Vector container,
ClassInterfaceSpec cis)
|
void |
main(int someNumber)
This meaningless method exists only to test the ability of this program to track multiple methods with the same name and different signatures. |
static void |
main(String[] args)
|
(package private) void |
processCode(ClassFile cf,
CodeAttrInfo cai,
MethodSpec currentMethodSpec)
This method walks through the ByteCode watching for more subtle dependencies that only show up in the Byte Code. |
(package private) void |
processCommandLineArgs(String[] args)
-s startingDirectory -mn methodNames -fn fieldNames -mc methodCalls -mcb methodCalledBy -fr fieldReference -ci classInstantiation |
void |
processDirectory(String directoryName)
This method implements the ProcessFileInterface |
void |
processFile(String className)
This method implements the method processFile() dictated by the interface ProcessFileInterface. |
void |
run(String[] args)
this method is used to run this class in stand-alone-mode in order to process a single class file |
(package private) void |
textualOutput()
|
(package private) static void |
usage()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
String d_topLevelPackageName
boolean d_firstTimeCalled
Spec d_currentPackageSpec
String d_currentClassInterfaceName
ClassInterfaceSpec d_currentClassInterfaceSpec
String d_rootPackageName
String d_startingDirectory
String d_outputDirectory
public static final String DEFAULT_ROOT_PACKAGE_NAME
Constructor Detail |
public xref()
Method Detail |
void addClass(String classSpec) throws Exception
Exception
public void processDirectory(String directoryName)
processDirectory
in interface ProcessFileInterface
ProcessFileInterface
public boolean directoryNameOk(String directoryName)
directoryNameOk
in interface ProcessFileInterface
ProcessFileInterface
public boolean fileTypeOk(String fileName)
fileTypeOk
in interface ProcessFileInterface
ProcessFileInterface
void exceptionCheck(ClassInterfaceSpec cis)
public void processFile(String className)
processFile
in interface ProcessFileInterface
ProcessFileInterface
void getParentInterfaces(Vector container, ClassInterfaceSpec cis)
void directoryCheck(String dirName)
void processCommandLineArgs(String[] args)
void processCode(ClassFile cf, CodeAttrInfo cai, MethodSpec currentMethodSpec) throws Exception
1. use of the INSTANCEOF instruction 2. reference to a field in a class 3. instantiation of a class 4. call to a method in a class
Exception
static void usage()
void textualOutput()
public void run(String[] args)
public void main(int someNumber)
public static void main(String[] args)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |