public class JGrep
extends java.lang.Object
java org.codehaus.janino.JGrep \ [ -dirs directory-name-patterns ] \ [ -files file-name-patterns ] \ { directory-path } \ -method-invocation class.method(arg-types) java org.codehaus.janino.JGrep -helpIf "-dirs" is not given, then all directory-pathes are scanned for files. The directory-name-patterns work as described in
StringPattern.parseCombinedPattern(String)
.
If "-files" is not given, then all files ending in ".java" are read. The
file-name-patterns work as described in
StringPattern.parseCombinedPattern(String)
.
Modifier and Type | Class and Description |
---|---|
private static class |
JGrep.Action |
private class |
JGrep.JGrepIClassLoader
A specialized
IClassLoader that loads IClass es from the following
sources:
An already-parsed compilation unit
A class file in the output directory (if existant and younger than source file)
A source file in any of the source path directories
The parent class loader
Notice that the JGrep.JGrepIClassLoader is an inner class of JGrep and
heavily uses JGrep 's members. |
(package private) static interface |
JGrep.MethodInvocationAction
An entity that does something with a method invocation, e.g.
|
(package private) static interface |
JGrep.MethodInvocationPredicate
A predicate that examines a method invocation.
|
private static class |
JGrep.MethodInvocationTarget |
Modifier and Type | Field and Description |
---|---|
private Benchmark |
benchmark |
private static boolean |
DEBUG |
private IClassLoader |
iClassLoader |
private java.lang.String |
optionalCharacterEncoding |
private java.util.List<UnitCompiler> |
parsedCompilationUnits |
private static java.lang.String[] |
USAGE |
Constructor and Description |
---|
JGrep(java.io.File[] classPath,
java.io.File[] optionalExtDirs,
java.io.File[] optionalBootClassPath,
java.lang.String optionalCharacterEncoding,
boolean verbose) |
JGrep(IClassLoader iClassLoader,
java.lang.String optionalCharacterEncoding,
boolean verbose) |
Modifier and Type | Method and Description |
---|---|
static java.io.File |
getClassFile(java.lang.String className,
java.io.File sourceFile,
java.io.File optionalDestinationDirectory)
Construct the name of a file that could store the byte code of the class with the given
name.
|
private void |
jGrep(java.io.File[] rootDirectories,
StringPattern[] directoryNamePatterns,
StringPattern[] fileNamePatterns,
java.util.List<JGrep.MethodInvocationTarget> methodInvocationTargets) |
private void |
jGrep(java.util.Iterator<java.io.File> sourceFilesIterator,
java.util.List<JGrep.MethodInvocationTarget> methodInvocationTargets) |
static void |
main(java.lang.String[] args)
Command line interface.
|
private Java.CompilationUnit |
parseCompilationUnit(java.io.File sourceFile,
java.lang.String optionalCharacterEncoding)
Read one compilation unit from a file and parse it.
|
private static JGrep.MethodInvocationTarget |
parseMethodInvocationPattern(java.lang.String mip) |
private static java.lang.String |
readIdentifierPattern(Parser p) |
(package private) static boolean |
typeMatches(java.lang.String pattern,
java.lang.String typeName) |
private static final boolean DEBUG
private final java.util.List<UnitCompiler> parsedCompilationUnits
private static final java.lang.String[] USAGE
private final IClassLoader iClassLoader
private final java.lang.String optionalCharacterEncoding
private final Benchmark benchmark
public JGrep(java.io.File[] classPath, java.io.File[] optionalExtDirs, java.io.File[] optionalBootClassPath, java.lang.String optionalCharacterEncoding, boolean verbose)
public JGrep(IClassLoader iClassLoader, java.lang.String optionalCharacterEncoding, boolean verbose)
public static void main(java.lang.String[] args)
private static JGrep.MethodInvocationTarget parseMethodInvocationPattern(java.lang.String mip) throws CompileException, java.io.IOException
CompileException
java.io.IOException
private static java.lang.String readIdentifierPattern(Parser p) throws CompileException, java.io.IOException
CompileException
java.io.IOException
static boolean typeMatches(java.lang.String pattern, java.lang.String typeName)
typeName
matches the pattern
, or, iff the pattern does not
contain a period, the simple type name of typeName
matches the pattern
private void jGrep(java.io.File[] rootDirectories, StringPattern[] directoryNamePatterns, StringPattern[] fileNamePatterns, java.util.List<JGrep.MethodInvocationTarget> methodInvocationTargets) throws CompileException, java.io.IOException
CompileException
java.io.IOException
private void jGrep(java.util.Iterator<java.io.File> sourceFilesIterator, java.util.List<JGrep.MethodInvocationTarget> methodInvocationTargets) throws CompileException, java.io.IOException
CompileException
java.io.IOException
private Java.CompilationUnit parseCompilationUnit(java.io.File sourceFile, java.lang.String optionalCharacterEncoding) throws CompileException, java.io.IOException
The inputStream
is closed before the method returns.
CompileException
java.io.IOException
public static java.io.File getClassFile(java.lang.String className, java.io.File sourceFile, java.io.File optionalDestinationDirectory)
If optionalDestinationDirectory
is non-null, the returned path is the
optionalDestinationDirectory
plus the package of the class (with dots replaced
with file separators) plus the class name plus ".class". Example:
"destdir/pkg1/pkg2/Outer$Inner.class"
If optionalDestinationDirectory
is null, the returned path is the
directory of the sourceFile
plus the class name plus ".class". Example:
"srcdir/Outer$Inner.class"
className
- E.g. "pkg1.pkg2.Outer$Inner"sourceFile
- E.g. "srcdir/Outer.java"optionalDestinationDirectory
- E.g. "destdir"