org.apache.tools.ant.taskdefs.optional.sitraka.bytecode
Class ClassPathLoader
java.lang.Object
|
+--org.apache.tools.ant.taskdefs.optional.sitraka.bytecode.ClassPathLoader
- public class ClassPathLoader
- extends java.lang.Object
Core of the bytecode analyzer. It loads classes from a given classpath.
- Author:
- Stephane Bailliez
Constructor Summary |
ClassPathLoader(java.io.File[] entries)
create a new instance with a given set of urls |
ClassPathLoader(java.lang.String classPath)
create a new instance with a given classpath. |
ClassPathLoader(java.lang.String[] entries)
create a new instance with a given set of urls. |
Method Summary |
static java.io.InputStream |
getCachedStream(java.io.InputStream is)
useful methods to read the whole input stream in memory so that
it can be accessed faster. |
java.util.Hashtable |
getClasses()
return the whole set of classes in the classpath. |
java.util.Enumeration |
loaders()
|
static void |
main(java.lang.String[] args)
dirty little test, should be moved to a testcase |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NULL_LOADER
public static final ClassPathLoader.FileLoader NULL_LOADER
files
protected java.io.File[] files
- the list of files to look for
ClassPathLoader
public ClassPathLoader(java.lang.String classPath)
- create a new instance with a given classpath. It must be urls
separated by the platform specific path separator.
- Parameters:
classPath
- the classpath to load all the classes from.
ClassPathLoader
public ClassPathLoader(java.lang.String[] entries)
- create a new instance with a given set of urls.
- Parameters:
entries
- valid file urls (either .jar, .zip or directory)
ClassPathLoader
public ClassPathLoader(java.io.File[] entries)
- create a new instance with a given set of urls
- Parameters:
entries
- file urls to look for classes (.jar, .zip or directory)
loaders
public java.util.Enumeration loaders()
- Returns:
- the set of FileLoader loaders matching the given classpath.
getClasses
public java.util.Hashtable getClasses()
throws java.io.IOException
- return the whole set of classes in the classpath. Note that this method
can be very resource demanding since it must load all bytecode from
all classes in all resources in the classpath at a time.
To process it in a less resource demanding way, it is maybe better to
use the loaders() that will return loader one by one.
- Returns:
- the hashtable containing ALL classes that are found in the given
classpath. Note that the first entry of a given classname will shadow
classes with the same name (as a classloader does)
main
public static void main(java.lang.String[] args)
throws java.lang.Exception
- dirty little test, should be moved to a testcase
getCachedStream
public static java.io.InputStream getCachedStream(java.io.InputStream is)
throws java.io.IOException
- useful methods to read the whole input stream in memory so that
it can be accessed faster. Processing rt.jar and tools.jar from JDK 1.3.1
brings time from 50s to 7s.
Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.