Possible Extensions to the Cross Reference Tool
Throughout the code there are suggestions on how this tool can
be extended/improved. Here are a few ideas for extension
for the "interested reader":
- Sort the elements that are listed in the report.
- Modify the tool to use Java's Class.forName
method to read class information for classes whose source
is unavailable. For example, if your source code
references java.awt.Color, use Class.forName("java.awt.Color")
to read information about the Color class.
You can define a new Definition subclass that
adapts a java.lang.Class object to a ClassDef
object, allowing you to reference compiled classes as
easily as source.
- The tool currently resolves methods based only on the name
of the method and the number of parameters to
it, not on parameter types. This is a necessary
because information contained in compiled bytecode
(.class) files is not available to properly resolve type
conversions. Once you've used Class.forName
to read compiled bytecode information, you can use that
information to properly resolve methods!
- Store access modifier information and report it.
- Add array support. There's an ArrayDef
class in the tool, but it is not currently used.
- Find places to make the tool more efficient. The
current implementation was written to make it easier to
understand, and could be made more efficient in many
places.
- Add more robust error handling, possibly implementing
some Java type checking.
- Report information about which symbols are referenced by
methods, classes, and so on.
- Report partial references. For example, java.awt.Component.width
is currently listed only as a reference to the width
variable of java.awt.Component. You could
extend this to make it a reference to class java.awt.Component
and package java.awt as well.