Background for the header
To the home page of the University of Antwerp




version 1.0 (April, 1rst 2004)

DOWNLOAD [ 12.9 KB ZIP file ]


Turns java programs (.class or .jar files) into famix files (.cdif files, see see ). Famix files then can be loaded into the MOOSE reengineering tool suite, which among others comprises CodeCrawler.

This tool uses the java.lang.reflect interface (hence the 'R' in the name javaR2famix), thus is a very lightweight means to parse java bytecode into famix-files with the extra advantage of being robust towards changes in the java-syntax and semantics. However, javaR2famix cannot extract the full information stored in the bytecode files (method invocations and attribute accesses). Also, its not able to compute useful metrics, which are often used during reengineering (e.g javaR2famix the number of lines of code of a class (LOC)).


  • Compile

    Perhaps you may need to compile the program on your particular platform. How this is done depends on the platform you're running on, but normally its done via a simple (assuming the file is inside the directory home/famix)

    [home] cd famix
    [famix] javac
    [famix] ls
  • Run: classpath & main program

    Running the program requires that you set the java classpath to include at least the path to the 'javaR2famix.class' file (the one you just compiled) and the java programs which you want to extract famix files from. Also, you must supply the name of the class containing the 'main' function, which should be 'famix.javaR2famix'

    [famix] cd ..
    [home] java famix.javaR2famix
    Usage: javaR2famix systemName (classNames | @filenames)
  • Run: command line arguments

    javaR2famix normally requires additional parameters to tell the program (a) the name of the system it is extracting, (b) for which classes the extractor should generate famix information. The first command line argument is These can be passed immediately, listing one class aftyer another separated by spaces, or via a text file, listing the filenames preceeded with a '@' character. The lines of these filenames should contain lines with the class names in the format as produced by the jar tool.

  • Example 1 (run the program on itself):

    [home] java famix.javaR2famix javaR2famix famix.javaR2famix > javaR2famix.cdif
    [home] ls javaR2famix.cdif

    Here's an explanation of the parameters

    • java - the virtual machine
    • famix.javaR2famix - the class containing the main function (should be in a subdirectory 'famix' from your current directory)
    • javaR2famix - the system name
    • famix.javaR2famix - the name of the class to be extracted
    • javaR2famix.cdif - the text file containing the output
  • Example 2 (run the program on a large .jar file):

    First use the jar tool to dump the contents of a jar file on a text file. To do that, pass the tf options ('t' for table of contents, 'f' for file) followed by the complete filename of the .jar file

    [home] jar tf /Applications/eclipse/plugins/org.eclipse.jdt.core_2.1.2/jdtcore.jar > EclipseClassList.txt

    Then run the javaR2famix, passing the appropriate classpath, the system name, and the name of the file containing the class names

    [home] sergedemeyer% java -cp ":/Applications/eclipse/plugins/org.eclipse.jdt.core_2.1.2/jdtcore.jar" famix.javaR2famix eclipse @EclipseClassList.txt > eclipse.cdif

    This will probably generate a lot of warnings style

    >>> Error when processing org.eclipse.jdt.core.ToolFactory
    Exception java.lang.NoClassDefFoundError: org/eclipse/core/runtime/CoreException

    But these can be safely ignored; it just means that not the jar file is incomplete.


Written by Serge Demeyer, director of the Lab On REengineering (LORE)

Valid HTML 4.01! Valid CSS!

 Lab On REengineering - Antwerpen, last modified 16:24:57 06 April 2009