tcl.lang
Class TclClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by tcl.lang.TclClassLoader

public class TclClassLoader
extends ClassLoader

TclClassLoader.java -- Implements the Class Loader for dynamically loading Tcl packages. When attempting to resolve and load a new Package the loader looks in four places to find the class. In order they are: 1) The unique cache, "classes", inside the TclClassLoader. 2) Using the system class loader (via the context class loader). 3) Any paths passed into the constructor via the pathList variable. 4) Any path in the interps env(TCL_CLASSPATH) variable. The class will be found if it is any of the above paths or if it is in a jar file located in one of the paths. TclClassLoader.java -- A class that helps filter directory listings when for jar/zip files during the class resolution stage. Copyright (c) 1997 by Sun Microsystems, Inc. See the file "license.terms" for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.


Constructor Summary
TclClassLoader(Interp interp, TclObject pathList, ClassLoader parent)
           
 
Method Summary
 Class defineClass(String className, byte[] classData)
          Given an array of bytes that define a class, create the Class.
 void dispose()
          Release resources, to ensure that interp has no references (especially in a container environment.)
protected  URL findResource(String resName)
          Resolves the specified resource name to a URL via a search of env(TCL_CLASSPATH).
 URL getResource(String resName)
          Attempt to resolve a resource using the parent class loader and then the tcl class loader.
 Class loadClass(String className)
          Resolves the specified name to a Class.
protected  Class loadClass(String className, boolean resolveIt)
          Resolves the specified name to a Class.
 void removeCache(String className)
          Remove the given className from the internal cache.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResources, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TclClassLoader

public TclClassLoader(Interp interp,
                      TclObject pathList,
                      ClassLoader parent)
Method Detail

dispose

public void dispose()
Release resources, to ensure that interp has no references (especially in a container environment.)


loadClass

public Class loadClass(String className)
                throws ClassNotFoundException,
                       PackageNameException
Resolves the specified name to a Class. This method differs from the regular loadClass(String) because it always passes a true resolveIt argument to loadClass(String, boolean). Results: the resolved Class, or null if it was not found. Side effects: ClassNotFoundException if the class loader cannot find a definition for the class.

Overrides:
loadClass in class ClassLoader
Throws:
ClassNotFoundException
PackageNameException
See Also:
ClassLoader.loadClass(java.lang.String)

loadClass

protected Class loadClass(String className,
                          boolean resolveIt)
                   throws ClassNotFoundException,
                          PackageNameException,
                          SecurityException
Resolves the specified name to a Class. The method loadClass() is called by the JavaLoadCmd and via Interp.loadClass(). Results: the resolved Class, or null if it was not found. Side effects: ClassNotFoundException if the class loader cannot find a definition for the class.

Overrides:
loadClass in class ClassLoader
Throws:
ClassNotFoundException
PackageNameException
SecurityException
See Also:
ClassLoader.loadClass(java.lang.String, boolean)

findResource

protected URL findResource(String resName)
                    throws PackageNameException
Resolves the specified resource name to a URL via a search of env(TCL_CLASSPATH). This method is invoked by getResource() when a resource has not been found by the system loader or the parent loader. Results: the resolved URL, or null if it was not found. Side effects: None.

Overrides:
findResource in class ClassLoader
Throws:
PackageNameException
See Also:
ClassLoader.findResource(java.lang.String)

getResource

public URL getResource(String resName)
Attempt to resolve a resource using the parent class loader and then the tcl class loader. This method seems to be needed because the JDK is not behaving the way it should as it is not loading resources from the parent. Results: the resolved URL, or null if it was not found. Side effects: None.

Overrides:
getResource in class ClassLoader
See Also:
ClassLoader.getResource(java.lang.String)

defineClass

public Class defineClass(String className,
                         byte[] classData)
Given an array of bytes that define a class, create the Class. If the className is null, we are creating a lambda class. Otherwise cache the className and definition in the loaders cache. Results: A Class object or null if it could not be defined. Side effects: Cache the Class object in the classes Hashtable.

Parameters:
className - Name of the class, possibly null
classData - Binary data of the class structure.
Returns:
A Class object or null if it could not be defined.

removeCache

public void removeCache(String className)
Remove the given className from the internal cache. Results: |>None.<| Side effects: |>None.<|

Parameters:
className -


Copyright © 2015. All rights reserved.