ccl.jcf
Class JCFUtil

java.lang.Object
  |
  +--ccl.jcf.JCFUtil

public class JCFUtil
extends java.lang.Object

An utility class to work with java byte code files. It uses Matt Yourst's Java Class File library.

The highlight of this class is the getMethodCallees method. It returns all methods which are invoked inside a given java method and java class.
Another highlight is the 'jwhich' method which does for java classes, what 'which' does for executables on unix.

Also provided are methods to find java class files on the file system or inside jar archives.


Constructor Summary
JCFUtil()
           
 
Method Summary
static java.lang.String getAbsoluteClassFileName(java.lang.String sFullClassName_, java.lang.String sClasspath_)
          Deprecated. see ccl.util.ClassPathUtil.
static java.lang.String getApplicationHome(java.lang.Object oClass)
          Deprecated. see ccl.util.ClassPathUtil.
static java.lang.String getClassOrJarFileName(java.lang.String sFullClassName_)
          Deprecated. see ccl.util.ClassPathUtil.
static java.lang.String getClassOrJarFileName(java.lang.String sFullClassName_, java.lang.String sClasspath_)
          Deprecated. see ccl.util.ClassPathUtil.
static java.lang.String getJarFileName(java.lang.String sFullClassName_)
          Deprecated. see ccl.util.ClassPathUtil.
static java.lang.String getJarFileName(java.lang.String sFullClassName_, java.lang.String sClasspath_)
          Deprecated. see ccl.util.ClassPathUtil.
static java.util.Hashtable getMethodCallees(java.awt.Frame frmParent_, java.lang.String sClassFullFileName_, java.lang.String sMethod_)
          Get all methods which are invoked inside a given method.
static java.lang.String getParameters(java.lang.String sSignature_)
          Convert an internal java byte code signature to a format which is more presentable to human users.
static java.lang.String jwhich(java.lang.String sClassName_, java.lang.String sClasspath_)
          Deprecated. see ccl.util.ClassPathUtil.
static lti.java.jcf.JcfClassFile readClassFile(byte[] abClass_)
          Convert a byte array to a JcfClassFile object.
static lti.java.jcf.JcfClassFile readClassFile(java.lang.String sClassFullFileName_)
          Create a JcfClassFile object reading from the file system.
static lti.java.jcf.JcfClassFile readClassFile(java.lang.String sFullClassName_, java.lang.String sClasspath_)
          Create a JcfClassFile object reading from the file system.
static lti.java.jcf.JcfClassFile readClassFile(java.util.zip.ZipFile zipOpen_, java.util.zip.ZipEntry pZipEntry_)
          Get a JcfClassFile object out of jar or zip file.
static lti.java.jcf.JcfClassFile readClassFromJar(java.lang.String sFullClassName_, java.lang.String sClasspath_)
          Load a class into an JcfClassFile object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCFUtil

public JCFUtil()
Method Detail

getAbsoluteClassFileName

public static java.lang.String getAbsoluteClassFileName(java.lang.String sFullClassName_,
                                                        java.lang.String sClasspath_)
Deprecated. see ccl.util.ClassPathUtil.

Finds the location in the file system of a java class file.

Returns:
null could not be found in the given classpath or if class is hidden in a jar file. In this case use 'getJarFileName()'.

getJarFileName

public static java.lang.String getJarFileName(java.lang.String sFullClassName_)
                                       throws java.io.IOException,
                                              java.util.zip.ZipException
Deprecated. see ccl.util.ClassPathUtil.

Provide a classname (e.g. ccl.jcf.JCFUtil) and a classpath, and you will get the jar file location which contains this class (e.g. lib/ccl.jar).

Throws:
java.io.IOException - if a file operation failed.
java.util.zip.ZipException - if any zip operation failed.

getJarFileName

public static java.lang.String getJarFileName(java.lang.String sFullClassName_,
                                              java.lang.String sClasspath_)
                                       throws java.io.IOException,
                                              java.util.zip.ZipException
Deprecated. see ccl.util.ClassPathUtil.

Provide a classname (e.g. ccl.jcf.JCFUtil) and a classpath, and you will get the jar file location which contains this class (e.g. lib/ccl.jar).

Throws:
java.io.IOException - if a file operation failed.
java.util.zip.ZipException - if any zip operation failed.

readClassFromJar

public static lti.java.jcf.JcfClassFile readClassFromJar(java.lang.String sFullClassName_,
                                                         java.lang.String sClasspath_)
                                                  throws java.io.IOException,
                                                         java.util.zip.ZipException
Load a class into an JcfClassFile object. Then you can inspect this class with the help of the jcf library.

Throws:
java.io.IOException - if a file operation failed.
java.util.zip.ZipException - if any zip operation failed.

readClassFile

public static lti.java.jcf.JcfClassFile readClassFile(byte[] abClass_)
                                               throws java.io.IOException
Convert a byte array to a JcfClassFile object.

Throws:
java.io.IOException - if a file operation failed.

readClassFile

public static lti.java.jcf.JcfClassFile readClassFile(java.util.zip.ZipFile zipOpen_,
                                                      java.util.zip.ZipEntry pZipEntry_)
                                               throws java.io.IOException,
                                                      java.util.zip.ZipException
Get a JcfClassFile object out of jar or zip file.

Throws:
java.io.IOException - if a file operation failed.
java.util.zip.ZipException - if any zip operation failed.

getClassOrJarFileName

public static java.lang.String getClassOrJarFileName(java.lang.String sFullClassName_)
                                              throws java.io.IOException,
                                                     java.lang.ClassNotFoundException,
                                                     java.util.zip.ZipException
Deprecated. see ccl.util.ClassPathUtil.

Either the absolut file name and path is given back or the java archive file name which contains this class is given back.

Throws:
java.lang.ClassNotFoundException - if the given class could not be found.
java.io.IOException - if a file operation failed.
java.util.zip.ZipException - if any zip operation failed.

getClassOrJarFileName

public static java.lang.String getClassOrJarFileName(java.lang.String sFullClassName_,
                                                     java.lang.String sClasspath_)
                                              throws java.io.IOException,
                                                     java.lang.ClassNotFoundException,
                                                     java.util.zip.ZipException
Deprecated. see ccl.util.ClassPathUtil.

Either the absolut file name and path is given back or the java archive file name which contains this class is given back.

Throws:
java.lang.ClassNotFoundException - if the given class could not be found.
java.io.IOException - if a file operation failed.
java.util.zip.ZipException - if any zip operation failed.

readClassFile

public static lti.java.jcf.JcfClassFile readClassFile(java.lang.String sFullClassName_,
                                                      java.lang.String sClasspath_)
                                               throws java.io.IOException,
                                                      java.lang.ClassNotFoundException,
                                                      java.util.zip.ZipException
Create a JcfClassFile object reading from the file system.

Throws:
java.lang.ClassNotFoundException - if the given class could not be found.
java.io.IOException - if a file operation failed.
java.util.zip.ZipException - if any zip operation failed.

readClassFile

public static lti.java.jcf.JcfClassFile readClassFile(java.lang.String sClassFullFileName_)
                                               throws java.io.IOException
Create a JcfClassFile object reading from the file system.

Throws:
java.io.IOException - if a file operation failed.

getParameters

public static java.lang.String getParameters(java.lang.String sSignature_)
Convert an internal java byte code signature to a format which is more presentable to human users.


getMethodCallees

public static java.util.Hashtable getMethodCallees(java.awt.Frame frmParent_,
                                                   java.lang.String sClassFullFileName_,
                                                   java.lang.String sMethod_)
Get all methods which are invoked inside a given method.

Parameters:
frmParent_ - Needed to report error messages.

jwhich

public static java.lang.String jwhich(java.lang.String sClassName_,
                                      java.lang.String sClasspath_)
Deprecated. see ccl.util.ClassPathUtil.

Like which for unix, finds the location of a given java class,
e.g. jwhich ccl.util.Test
-> /home/clemens/bunin/ccl/lib/ccl.jar
or
-> /home/clemens/bunin/ccl/classes/ccl/util/Test.class .

Returns:
null if nothing was found.

getApplicationHome

public static java.lang.String getApplicationHome(java.lang.Object oClass)
Deprecated. see ccl.util.ClassPathUtil.

This method searches in the current classpath for the given object. That class should be either in a jar file which is located inside a lib directory or as a pure class file under a classes directory. The directory containing either the classes or the lib directory will be returned as the applicaton home directory. If this is not found, null is returned.

Parameters:
oClass - An instantiated class which belongs to the application.
Returns:
null if no home directory was found.