Bsh has a multi-tiered class loading architecture. No class loader is used unless/until the classpath is modified or a class is reloaded.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | |
| pack-priv static class | BshClassManager.SignatureKey
SignatureKey serves as a hash of a method signature on a class for fast lookup of overloaded and general resolved Java methods. |
| Modifier and Type | Field and Description |
|---|---|
| protected transient Hashtable | absoluteClassCache
Global cache for things we know are classes. |
| protected transient Hashtable | absoluteNonClasses
Global cache for things we know are *not* classes. |
| private Interpreter | declaringInterpreter
The interpreter which created the class manager This is used to load scripted classes from source files. |
| protected transient Hashtable | |
| protected transient Hashtable | |
| protected ClassLoader | externalClassLoader
An external classloader supplied by the setClassLoader() command. |
| private static Object | NOVALUE
Identifier for no value item. |
| protected transient Hashtable | resolvedObjectMethods
Caches for resolved object and static methods. |
| protected transient Hashtable |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | cacheClassInfo(String name, Class<T>
if value is non-null, cache the class
if value is null, set the flag that it is *not* a class to
speed later resolution value)Cache info about whether name is a class or not. |
| public void | cacheResolvedMethod(Class<T> clas, Class<T>[] types, Method method)
Cache a resolved (possibly overloaded) method based on the argument types used to invoke it, subject to classloader change. |
| public boolean | |
| public Class | Returns: the class or nullLoad the specified class by name, taking into account added classpath and reloaded classes, etc. Note Again, this is just a trivial implementation. |
| protected void | |
| protected void | |
| protected static UtilEvalError | |
| public static BshClassManager | |
| public Class | |
| protected void | |
| protected void | doneDefiningClass(String className)
Indicate that the specified class name has been defined and may be loaded normally. |
| protected void | |
| public void | |
| protected String | getClassBeingDefined(String className)
This method is a temporary workaround used with definingClass. |
| protected String | getClassNameByUnqName(String name)
Return the name or null if none is found, Throw an ClassPathException containing detail if name is ambigous. |
| protected Method | Returns: the Method or nullspecifies that only a static method may be returned. onlyStatic)Return a previously cached resolved method. |
| public URL | |
| public InputStream | getResourceAsStream(String
should be an absolute path path)Get a resource stream using the BeanShell classpath |
| protected boolean | |
| protected boolean | |
| protected Class | |
| protected static Error | noClassDefFound(String className, Error e)
Annotate the NoClassDefFoundError with some info about the class we were trying to load. |
| public Class | Returns: the classPerform a plain Class.forName() or call the externally provided classloader. |
| public void | |
| public void | reloadClasses(String[] classNames)
Reloading classes means creating a new classloader and using it whenever we are asked for classes in the appropriate space. |
| public void | reloadPackage(String pack)
Reload all classes in the specified package: e.g. "com.sun.tools" The special package name "<unpackaged>" can be used to refer to unpackaged classes. |
| public void | |
| public void | |
| public void | |
| public void |
| absoluteClassCache | back to summary |
|---|---|
| protected transient Hashtable<K, V> absoluteClassCache Global cache for things we know are classes. Note these should probably be re-implemented with Soft references. (as opposed to strong or Weak) | |
| absoluteNonClasses | back to summary |
|---|---|
| protected transient Hashtable<K, V> absoluteNonClasses Global cache for things we know are *not* classes. Note these should probably be re-implemented with Soft references. (as opposed to strong or Weak) | |
| declaringInterpreter | back to summary |
|---|---|
| private Interpreter declaringInterpreter The interpreter which created the class manager This is used to load scripted classes from source files. | |
| definingClasses | back to summary |
|---|---|
| protected transient Hashtable<K, V> definingClasses | |
| definingClassesBaseNames | back to summary |
|---|---|
| protected transient Hashtable<K, V> definingClassesBaseNames | |
| externalClassLoader | back to summary |
|---|---|
| protected ClassLoader externalClassLoader An external classloader supplied by the setClassLoader() command. | |
| NOVALUE | back to summary |
|---|---|
| private static Object NOVALUE Identifier for no value item. Use a hashtable as a Set. | |
| resolvedObjectMethods | back to summary |
|---|---|
| protected transient Hashtable<K, V> resolvedObjectMethods Caches for resolved object and static methods. We keep these maps separate to support fast lookup in the general case where the method may be either. | |
| resolvedStaticMethods | back to summary |
|---|---|
| protected transient Hashtable<K, V> resolvedStaticMethods | |
| BshClassManager | back to summary |
|---|---|
| public BshClassManager() | |
| addClassPath | back to summary |
|---|---|
| public void addClassPath(URL path) throws IOException | |
| addListener | back to summary |
|---|---|
| public void addListener(BshClassManager. | |
| cacheClassInfo | back to summary |
|---|---|
| public void cacheClassInfo(String name, Class<T> value) Cache info about whether name is a class or not.
| |
| cacheResolvedMethod | back to summary |
|---|---|
| public void cacheResolvedMethod(Class<T> clas, Class<T>[] types, Method method) Cache a resolved (possibly overloaded) method based on the argument types used to invoke it, subject to classloader change. Static and Object methods are cached separately to support fast lookup in the general case where either will do. | |
| classExists | back to summary |
|---|---|
| public boolean classExists(String name) | |
| classForName | back to summary |
|---|---|
| public Class Load the specified class by name, taking into account added classpath and reloaded classes, etc. Note Again, this is just a trivial implementation. See bsh.classpath.ClassManagerImpl for the fully functional class management package.
| |
| classLoaderChanged | back to summary |
|---|---|
| protected void classLoaderChanged() | |
| clearCaches | back to summary |
|---|---|
| protected void clearCaches() Clear the caches in BshClassManager
| |
| cmUnavailable | back to summary |
|---|---|
| protected static UtilEvalError cmUnavailable() | |
| createClassManager | back to summary |
|---|---|
| public static BshClassManager createClassManager(Interpreter interpreter) Create a new instance of the class manager. Class manager instnaces are now associated with the interpreter. | |
| defineClass | back to summary |
|---|---|
| public Class | |
| definingClass | back to summary |
|---|---|
| protected void definingClass(String className) Flag the class name as being in the process of being defined. The class manager will not attempt to load it. | |
| doneDefiningClass | back to summary |
|---|---|
| protected void doneDefiningClass(String className) Indicate that the specified class name has been defined and may be loaded normally. | |
| doSuperImport | back to summary |
|---|---|
| protected void doSuperImport() throws UtilEvalError Support for "import *;" Hide details in here as opposed to NameSpace. | |
| dump | back to summary |
|---|---|
| public void dump(PrintWriter pw) | |
| getClassBeingDefined | back to summary |
|---|---|
| protected String getClassBeingDefined(String className) This method is a temporary workaround used with definingClass. It is to be removed at some point. | |
| getClassNameByUnqName | back to summary |
|---|---|
| protected String getClassNameByUnqName(String name) throws UtilEvalError Return the name or null if none is found, Throw an ClassPathException containing detail if name is ambigous. | |
| getResolvedMethod | back to summary |
|---|---|
| protected Method getResolvedMethod(Class<T> clas, String methodName, Class<T>[] types, boolean onlyStatic) Return a previously cached resolved method.
| |
| getResource | back to summary |
|---|---|
| public URL getResource(String path) Get a resource URL using the BeanShell classpath
| |
| getResourceAsStream | back to summary |
|---|---|
| public InputStream getResourceAsStream(String path) Get a resource stream using the BeanShell classpath
| |
| hasSuperImport | back to summary |
|---|---|
| protected boolean hasSuperImport() A "super import" ("import *") operation has been performed. | |
| isClassBeingDefined | back to summary |
|---|---|
| protected boolean isClassBeingDefined(String className) | |
| loadSourceClass | back to summary |
|---|---|
| protected Class | |
| noClassDefFound | back to summary |
|---|---|
| protected static Error noClassDefFound(String className, Error e) Annotate the NoClassDefFoundError with some info about the class we were trying to load. | |
| plainClassForName | back to summary |
|---|---|
| public Class Perform a plain Class.forName() or call the externally provided classloader. If a BshClassManager implementation is loaded the call will be delegated to it, to allow for additional hooks. This simply wraps that bottom level class lookup call and provides a central point for monitoring and handling certain Java version dependent bugs, etc.
| |
| reloadAllClasses | back to summary |
|---|---|
| public void reloadAllClasses() throws UtilEvalError Overlay the entire path with a new class loader. Set the base path to the user path + base path. No point in including the boot class path (can't reload thos). | |
| reloadClasses | back to summary |
|---|---|
| public void reloadClasses(String[] classNames) throws UtilEvalError Reloading classes means creating a new classloader and using it whenever we are asked for classes in the appropriate space. For this we use a DiscreteFilesClassLoader | |
| reloadPackage | back to summary |
|---|---|
| public void reloadPackage(String pack) throws UtilEvalError Reload all classes in the specified package: e.g. "com.sun.tools"
The special package name " | |
| removeListener | back to summary |
|---|---|
| public void removeListener(BshClassManager. | |
| reset | back to summary |
|---|---|
| public void reset() Clear all loaders and start over. No class loading. | |
| setClassLoader | back to summary |
|---|---|
| public void setClassLoader(ClassLoader externalCL) Set an external class loader. BeanShell will use this at the same point it would otherwise use the plain Class.forName(). i.e. if no explicit classpath management is done from the script (addClassPath(), setClassPath(), reloadClasses()) then BeanShell will only use the supplied classloader. If additional classpath management is done then BeanShell will perform that in addition to the supplied external classloader. However BeanShell is not currently able to reload classes supplied through the external classloader. | |
| setClassPath | back to summary |
|---|---|
| public void setClassPath(URL[] cp) throws UtilEvalError Set a new base classpath and create a new base classloader. This means all types change. | |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| classLoaderChanged | back to summary |
|---|---|
| public void classLoaderChanged() | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv Class | |
| pack-priv int | |
| pack-priv String | |
| pack-priv Class |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. o)Overrides java. |
| public int |
| clas | back to summary |
|---|---|
| pack-priv Class<T> clas | |
| hashCode | back to summary |
|---|---|
| pack-priv int hashCode | |
| methodName | back to summary |
|---|---|
| pack-priv String methodName | |
| types | back to summary |
|---|---|
| pack-priv Class<T>[] types | |
| SignatureKey | back to summary |
|---|---|
| pack-priv SignatureKey(Class<T> clas, String methodName, Class<T>[] types) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |