Package kilim.tools
Class Weaver
- java.lang.Object
-
- kilim.tools.Weaver
-
public class Weaver extends java.lang.ObjectThis class supports both command-line and run time weaving of Kilim bytecode.
-
-
Field Summary
Fields Modifier and Type Field Description KilimContextcontext(package private) static interrstatic java.util.regex.PatternexcludePatternstatic booleanforcestatic java.lang.StringoutputDirstatic booleanproxystatic booleanverbose
-
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 intdoMain(java.lang.String[] names, java.lang.String[] classpath)(package private) static booleanexclude(java.lang.String name)(package private) static java.lang.StringgetDirName(java.lang.String className)(package private) static voidhelp()static voidmain(java.lang.String[] args)Usage: java kilim.tools.Weaver -d <output directory> {source classe, jar, directory ...}(package private) static voidmkdir(java.lang.String dir)static java.util.ArrayList<java.lang.String>parseArgs(java.lang.String[] args)ClassWeaverweave(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.voidweaveFile(java.lang.String name, java.io.InputStream is)static voidwriteClass(ClassInfo ci)(package private) static voidwriteClasses(ClassWeaver cw)
-
-
-
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
-
context
public KilimContext context
-
-
Constructor Detail
-
Weaver
public Weaver(KilimContext $context)
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.io.IOExceptionUsage: 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 ./classesby 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
- 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:
KilimExceptionjava.io.IOException
-
-