Package kilim.tools

Class Weaver

java.lang.Object
kilim.tools.Weaver

public class Weaver extends Object
This class supports both command-line and run time weaving of Kilim bytecode.
  • Field Details

    • outputDir

      public static String outputDir
    • verbose

      public static boolean verbose
    • force

      public static boolean force
    • proxy

      public static boolean proxy
    • excludePattern

      public static Pattern excludePattern
    • err

      static int err
    • context

      public KilimContext context
  • Constructor Details

  • Method Details

    • main

      public static void main(String[] args) throws 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:
      IOException
      See Also:
    • concat

      private static String[] concat(String[] a, String[] b)
    • doMain

      public static int doMain(String[] names, String[] classpath) throws IOException
      Throws:
      IOException
    • exclude

      static boolean exclude(String name)
    • weave

      public ClassWeaver weave(InputStream is)
    • weaveFile

      public void weaveFile(String name, InputStream is) throws IOException
      Throws:
      IOException
    • writeClasses

      static void writeClasses(ClassWeaver cw) throws IOException
      Throws:
      IOException
    • writeClass

      public static void writeClass(ClassInfo ci) throws IOException
      Throws:
      IOException
    • mkdir

      static void mkdir(String dir) throws IOException
      Throws:
      IOException
    • getDirName

      static String getDirName(String className)
    • help

      static void help()
    • parseArgs

      public static ArrayList<String> parseArgs(String[] args) throws IOException
      Throws:
      IOException
    • weave

      public List<ClassInfo> weave(List<ClassInfo> classes) throws KilimException, 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
      IOException