Package kilim.tools

Class Weaver


  • public class Weaver
    extends java.lang.Object
    This class supports both command-line and run time weaving of Kilim bytecode.
    • Constructor Summary

      Constructors 
      Constructor Description
      Weaver​(KilimContext $context)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String[] concat​(java.lang.String[] a, java.lang.String[] b)  
      static int doMain​(java.lang.String[] names, java.lang.String[] classpath)  
      (package private) static boolean exclude​(java.lang.String name)  
      (package private) static java.lang.String getDirName​(java.lang.String className)  
      (package private) static void help()  
      static void main​(java.lang.String[] args)
      Usage: java kilim.tools.Weaver -d <output directory> {source classe, jar, directory ...}
      (package private) static void mkdir​(java.lang.String dir)  
      static java.util.ArrayList<java.lang.String> parseArgs​(java.lang.String[] args)  
      ClassWeaver weave​(java.io.InputStream is)  
      java.util.List<ClassInfo> weave​(java.util.List<ClassInfo> classes)
      Analyzes the list of supplied classes and inserts Kilim-related bytecode if necessary.
      void weaveFile​(java.lang.String name, java.io.InputStream is)  
      static void writeClass​(ClassInfo ci)  
      (package private) static void writeClasses​(ClassWeaver cw)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • outputDir

        public static java.lang.String outputDir
      • verbose

        public static boolean verbose
      • force

        public static boolean force
      • proxy

        public static boolean proxy
      • excludePattern

        public static java.util.regex.Pattern excludePattern
      • err

        static int err
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.io.IOException
         Usage: java kilim.tools.Weaver -d <output directory> {source classe, jar, directory ...}
         
        If directory names or jar files are given, all classes in that container are processed. It is perfectly fine to specify the same directory for source and output like this:
            java kilim.tools.Weaver -d ./classes ./classes
         
        by default, each element is added to the classpath (use -c to suppress classpath augmentation) arguments:
        • -d directory: write output to directory (required)
        • -f: force, write output even if output file is newer than source
        • -c: don't add source class list to the classpath
        • -h: print help info
        • -q: quiet
        • -x regex: exclude, skip classes matching regex
        Ensure that all classes to be woven are in the classpath. The output directory does not have to be in the classpath during weaving.
        Throws:
        java.io.IOException
        See Also:
        for run-time weaving.
      • concat

        private static java.lang.String[] concat​(java.lang.String[] a,
                                                 java.lang.String[] b)
      • doMain

        public static int doMain​(java.lang.String[] names,
                                 java.lang.String[] classpath)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • exclude

        static boolean exclude​(java.lang.String name)
      • weave

        public ClassWeaver weave​(java.io.InputStream is)
      • weaveFile

        public void weaveFile​(java.lang.String name,
                              java.io.InputStream is)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • writeClasses

        static void writeClasses​(ClassWeaver cw)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • writeClass

        public static void writeClass​(ClassInfo ci)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • mkdir

        static void mkdir​(java.lang.String dir)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • getDirName

        static java.lang.String getDirName​(java.lang.String className)
      • help

        static void help()
      • parseArgs

        public static java.util.ArrayList<java.lang.String> parseArgs​(java.lang.String[] args)
                                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • weave

        public java.util.List<ClassInfo> weave​(java.util.List<ClassInfo> classes)
                                        throws KilimException,
                                               java.io.IOException
        Analyzes the list of supplied classes and inserts Kilim-related bytecode if necessary. If a supplied class is dependent upon another class X, it is the caller's responsibility to ensure that X is either in the classpath, or loaded by the context classloader, or has been seen in an earlier invocation of weave(). Since weave() remembers method signatures from earlier invocations, the woven classes do not have to be classloaded to help future invocations of weave. If two classes A and B are not in the classpath, and are mutually recursive, they can be woven only if supplied in the same input list. This method is thread safe.
        Parameters:
        classes - A list of (className, byte[]) pairs. The first part is a fully qualified class name, and the second part is the bytecode for the class.
        Returns:
        A list of (className, byte[]) pairs. Some of the classes may or may not have been modified, and new ones may be added.
        Throws:
        KilimException
        java.io.IOException