|SWAG >> Javex|
Java fact extractor
This program performs fact extraction from java class files, with the output from this program being immediately viewable using LSEdit.
Javex is a fact extractor for Java, that extracts facts from the Java class files.
The latest builds of Javex are available below. While effort has been made to test Javex, the software may contain bugs.
Javex is being constantly developed and improved; check back often for newer versions.
This program extracts facts from java source and class files.
javex [-j/avac <program>] [-c/lasspath <path>] [-i/nput <file>] [-d/ynamic] [-e/dges <number>]* [-f/ields] [-l/ocals] [-m/utators] [-p/ermissions [-p/ermissions]] [-z/ero] [-v/erbose] *.[class|java]
If the -j option is specified javex will attempt to compile source files presented to it that have the suffix ".java" using the indicated program and classpath, prior to examining the corresponding class file. This compilation will itself use the '-g' option ensuring that the resulting class files contain symbolic variable information, source line number information, etc. Note that in the absence of the '-d/ynamic' option, this will result in inner classes contained in inner class files not being processed by javex, unless these inner class files are explicitly named. This option was introduced in version 1.0.4.
N.B If the -j option is not specified javex will ignore specified file names whose suffix ends in ".java".
If the -c option is specified this option should be followed by a list of directories, separated by ';', ':', or ',' where additional class files may be found. If the -j option is also specified this classpath must also conform to the syntax required by javac.
If the -d option is specified then having completed the initial processing of the named java source and/or class files, javex will attempt to iteratively find all classes cited but not yet processed, and process these class files too. It will search each location named in the classpath provided using the -c option, with the default classpath if none is specified being '.'. This results in an exhaustive search for all cited class files, and the subsequent dynamic processing of these initially unspecified class files. The consequent data capture may potentially be huge. If the -j option is also specified such dynamically discovered class files will be recompiled if their source is also located before themselves being processed. This may prove to be a lengthy process but ensures that all class files examined conform to their corresponding source files, and are compiled using the '-g' option. This option was introduced in version 1.0.4.
If the -i option is specified then in addition to processing any java source and/or class files specified directly on the command line, javax will also process those files named within the indicated file. The special filename '-' is interpreted as in instruction to read class file names from the standard input. Each such source/class file named within this file must begin on a new line and have neither blanks before or after it.
If the -f option is specified fields declared within classes will be captured, as will the manipulations performed on them, by the various methods that access them. As of 1.0.2 fields are not captured by default. Field edges will not be generated if this option is not specified.
If the -l option is specified local variables declared within methods and the parameters passed to methods (a subclass of such variables) will be captured. The distinction between parameters and other local variables was introduced in 1.0.7. As of 1.0.1 local variables are not captured by default. Variable edges will not be generated if this option is not specified.
If the -m option is specified then actions that access but do not mutate fields/variables/parameters will be represented by edges from these items to the method that accesses them. This helps distinguish between operations that access versus those that mutate variables. This option was added in 1.0.8. If this option is employed, the resulting landscape is best visualised in LSEdit by setting the options→draw edges→direct+side edges option.
Each -e option specified disables generation of the corresponding edge. This permits some up front tailoring of the contents of the resulting TA file. Currently valid numeric edge types are shown below. Those in capital letters correspond to pcode instructions, while those in mixed case correspond to properties of entities. This feature was introduced in version 1.0.3. Variable edges are only generated if the '-l' option is specified. Field edges are only generated if the '-f' option is specified.
If the -p option is specified then javex creates subclasses in the output for classes, methods, fields and variables for each possible access permission (private/protected/default/private protected/public). If the -p option is specified twice a subclass is created for private protected even if this access permission is never encountered in the class files examined. This option was introduced in version 1.0.5
If the -z option is specified then the instantiation edge (E263) always is from fields/variables directly to the class they instantiated, even when the field/variable instantiates arrays of this class. By default the edge is to the array class, when it is an array that is being instantiated. Thus the -z option instructs javex to treat all instantiations as if they involved zero array subscripts. This option was introduced in version 1.0.5.
If the -v option is specified then javex reports each class file processed, upon successful completion of that processing. The output will distinguish between class files explicitly processed as per the instructions provided to javex, and those class files implicitly processed as a consequence of having earlier been cited.
The standard output from this program conforms to TA, and is intended to be directly viewable by using lsedit.
If the class files have earlier been compiled using the -g option which is advisable, then the output will be suitably annotated with linenumber and source file information permitting hyper-linking of the viewed output to source code editors of the users choice.
In addition, if the class files have earlier been compiled using the -g option and the -l option is specified then variable names used within the pcode can be derived from the symbol tables encoded within the class files and these variable names will be included in the extraction.
Classes contained within source files correspond to those classes detected within the class files examined. Classes contained within source files that end in the suffix ".class" contained no instructions within the class file as to where the source could be found, and thus presumably were not earlier compiled using the '-g' option. Conversely classes contained within source files that end in ".java" were presumably compiled with the "-g" option and permit hyper-linking to these source files. Classes not contained within source files correspond to classes cited but not observed within the specified input class files, and if a class path is specified, not found within any directory named in that class path. Those items under the pseudo source file :datatypes: correspond to references to base datatypes observed within the class files. Member methods always occur within the class file that they belong to, fields likewise (if included in the output TA), and member variables (if included within the output TA) within the methods that declare them.
A reasonable attempt is made to unify the output directory structure by presuming that cited but not discovered classes logically reside within directories corresponding to the packages they belong to.
On swag to extract facts from lsedit, I might issue the command:
javex -j /usr/java/jdk1.5.0_06/bin/javac -v -d lsedit/LandscapeEditorCore.java > lsedit.ta
javex -j /usr/java/jdk1.5.0_06/bin/javac lsedit/*.java > lsedit.ta
Note the location of the java compileer javac may change. To determine its current location, try issuing on swag type javac when running under the sh shell or which javac when running under csh.
Another approach would be to issue the command:
javac -g lsedit/*.java
so as to compile all the java files in lsedit and then issue the command:
If you wish to also extract facts from frameworks such as AWT, SWING, etc. you will need to use the -d option, and specify using the -c classpath option where source or class files for these frameworks can be found. Note if such frameworks are not compiled output will be limited if the class file's read have not earlier been compiled using the -g option of javac.
Any that the source can be compiled on.
Contact informationFor more information on javex please contact us at .