Search:
Locator+ Code:
FTPOnline Magazines Newsletters Resources Partner Sites About FTP
Archives
 
 
 
 
 
 
 
 


email article
printer friendly
get the code
more resources

JSIS and Source Code Dependencies
JSIS provides a relatively easy API for building tools that can analyze, scrutinize, and operate on Java source code
by Claude Duguay

September 2003 Issue


ADVERTISEMENT

The Semantic Interface Specification for Java Technology (JSIS) is a unified API designed to build tools that do semantic and syntactic Java source analysis. It's the brainchild of Steve Blake and Tom Halliley, both of whom worked together on ASIS, a semantic interface for the Ada language applied primarily to government defense projects. As Steve and Tom became Java programmers, they discovered limitations in existing syntax parsers—no semantic name resolution, for example—and in Java reflection, which has no syntax capabilities. They decided to apply their expertise to create JSIS. The goal of JSIS is to make it useful for developing virtually any kind of Java syntactic or semantic tool.

The JSIS API provides a SAX-like, event-driven interface that makes it easy to traverse packages, classes, declarations, statements, expressions, and more. With it, you get fine-grained access to expression identifiers and literals, accurate token position information, comments of any kind, including single-line comments (which JavaDoc ignores), and pretty much any information you have access to using JavaDoc, Java reflection, or other similar tools. JSIS can even interoperate with the Java reflection API, allowing the creation of JSIS objects from Reflection objects and vice versa. JSIS can provide semantic information by using both source code and class files.

With JSIS several tool opportunities become more viable. Sample applications include browsing and navigation tools, code formatting and restructuring tools, source code generation tools, code coverage and test generation tools, code analysis and metric reporting tools, style and standard-compliance reporting, UML diagram and round-trip engineering tools, and interactive source code editing, to name just a few.

Here we'll take a closer look at JSIS by building a simple dependency analyzer. The analyzer takes a set of root classes as input and produces a list of classes that need to be present for the root classes to operate. You can also ask for a list of source code files instead of class names if you like. To make this operation more practical, we'll allow you to limit the packages in which to search. For example, when our dependencies package is used, you can collect files from this package only, leaving out standard Java classes like String or Object. The package prefix can be used like a path to keep the search constrained, which is useful for operating on your own classes without pulling in classes from external libraries or frameworks.

To get an application that uses JSIS up and running, you need to download the JSIS Personal/Evaluation Edition (see Resources), which is free for personal development or evaluation purposes. The JSIS Toolkit Edition is less than $50 a year if you need to use it commercially. If you use the library with a commercial tool, you'll be paying close to $500 a year, which is a fairly modest investment if you plan to make money with your application. The library is the same, regardless of the licensing option you choose. The version I'm using is 1.2, which requires a Java 2 Virtual Machine (JVM) that supports the java.lang.reflect package, a minimum of 128 MB of RAM (256 MB is recommended), and 20 MB of free disk space.

Back to top




Sponsored Links

Java Pro | | Visual Studio Magazine | XML & Web Services Magazine
| | Discussions | Newsletters | FTP Home