Class ClassFileUtilities


  • public class ClassFileUtilities
    extends java.lang.Object
    This class contains utility methods to manipulate Java classes.
    Version:
    $Id: ClassFileUtilities.java 1804130 2017-08-04 14:41:11Z ssteiner $
    • Constructor Detail

      • ClassFileUtilities

        protected ClassFileUtilities()
        This class does not need to be instantiated.
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
        Program that computes the dependencies between the Batik jars.

        Run this from the main Batik distribution directory, after building the jars. For every jar file in the batik-xxx/ build directory, it will determine which other jar files it directly depends on. The output is lines of the form:

          number,from,to

        where mean that the from jar has number class files that depend on class files in the to jar.

      • collectJars

        private static void collectJars​(java.io.File dir,
                                        java.util.Map jars,
                                        java.util.Map classFiles)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • getClassDependencies

        public static java.util.Set getClassDependencies​(java.lang.String path,
                                                         java.util.Set classpath,
                                                         boolean rec)
                                                  throws java.io.IOException
        Returns the dependencies of the given class.
        Parameters:
        path - The root class path.
        classpath - The set of directories (Strings) to scan.
        rec - Whether to follow dependencies recursively.
        Returns:
        a list of paths representing the used classes.
        Throws:
        java.io.IOException
      • getClassDependencies

        public static java.util.Set getClassDependencies​(java.io.InputStream is,
                                                         java.util.Set classpath,
                                                         boolean rec)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • computeClassDependencies

        private static void computeClassDependencies​(java.io.InputStream is,
                                                     java.util.Set classpath,
                                                     java.util.Set done,
                                                     java.util.Set result,
                                                     boolean rec)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • getClassDependencies

        public static java.util.Set getClassDependencies​(java.io.InputStream is)
                                                  throws java.io.IOException
        Returns the dependencies of the given class.
        Returns:
        a list of strings representing the used classes.
        Throws:
        java.io.IOException
      • getDescriptorClasses

        protected static java.util.Set getDescriptorClasses​(java.lang.String desc)
        Returns the classes contained in a field or method desciptor.