com.vladium.emma.rt
Class InstrClassLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byjava.net.URLClassLoader
              extended bycom.vladium.emma.rt.InstrClassLoader

public final class InstrClassLoader
extends java.net.URLClassLoader

Author:
Vlad Roubtsov, (C) 2003

Nested Class Summary
private static class InstrClassLoader.PoolEntry
           
 
Nested classes inherited from class java.lang.ClassLoader
 
Field Summary
private static int BAOS_INIT_SIZE
           
private static int BAOS_MAX_SIZE
           
private static int BAOS_POOL_SIZE
           
private static java.net.URL[] EMPTY_URL_ARRAY
           
private  InstrClassLoader.PoolEntry[] m_bufPool
           
private  java.util.Map m_cache
           
private  int m_cacheHits
           
private  int m_cacheMisses
           
private  IInclExclFilter m_forcedDelegationFilter
           
private  IClassLoadHook m_hook
           
private  Logger m_log
           
private  int m_nestLevel
           
private  java.lang.ClassLoader m_parent
           
private  IInclExclFilter m_throughDelegationFilter
           
static java.lang.String PROPERTY_FORCED_DELEGATION_FILTER
           
static java.lang.String PROPERTY_THROUGH_DELEGATION_FILTER
           
 
Fields inherited from class java.net.URLClassLoader
 
Fields inherited from class java.security.SecureClassLoader
 
Fields inherited from class java.lang.ClassLoader
 
Constructor Summary
InstrClassLoader(java.lang.ClassLoader parent, java.io.File[] classpath, IInclExclFilter forcedDelegationFilter, IInclExclFilter throughDelegationFilter, IClassLoadHook hook, java.util.Map cache)
           
 
Method Summary
private  InstrClassLoader.PoolEntry acquirePoolEntry()
           
 void debugDump(java.io.PrintWriter out)
           
private  java.lang.Class defineClass(java.lang.String className, byte[] bytes, int length, java.net.URL srcURL)
           
private static java.net.URL[] filesToURLs(java.io.File[] classpath)
           
protected  java.lang.Class findClass(java.lang.String name)
           
 java.net.URL getResource(java.lang.String name)
           
 java.lang.Class loadClass(java.lang.String name, boolean resolve)
          Overrides java.lang.ClassLoader.loadClass() to change the usual parent-child delegation rules just enough to be able to 'replace' the parent loader.
private static void readFully(java.io.InputStream in, ByteArrayOStream out, byte[] buf)
          Reads the entire contents of a given stream into a flat byte array.
private  void releasePoolEntry(InstrClassLoader.PoolEntry buf)
           
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_FORCED_DELEGATION_FILTER

public static final java.lang.String PROPERTY_FORCED_DELEGATION_FILTER
See Also:
Constant Field Values

PROPERTY_THROUGH_DELEGATION_FILTER

public static final java.lang.String PROPERTY_THROUGH_DELEGATION_FILTER
See Also:
Constant Field Values

m_parent

private final java.lang.ClassLoader m_parent

m_forcedDelegationFilter

private final IInclExclFilter m_forcedDelegationFilter

m_throughDelegationFilter

private final IInclExclFilter m_throughDelegationFilter

m_cache

private final java.util.Map m_cache

m_hook

private final IClassLoadHook m_hook

m_bufPool

private final InstrClassLoader.PoolEntry[] m_bufPool

m_log

private final Logger m_log

m_nestLevel

private int m_nestLevel

m_cacheHits

private int m_cacheHits

m_cacheMisses

private int m_cacheMisses

BAOS_INIT_SIZE

private static final int BAOS_INIT_SIZE
See Also:
Constant Field Values

BAOS_MAX_SIZE

private static final int BAOS_MAX_SIZE
See Also:
Constant Field Values

BAOS_POOL_SIZE

private static final int BAOS_POOL_SIZE
See Also:
Constant Field Values

EMPTY_URL_ARRAY

private static final java.net.URL[] EMPTY_URL_ARRAY
Constructor Detail

InstrClassLoader

public InstrClassLoader(java.lang.ClassLoader parent,
                        java.io.File[] classpath,
                        IInclExclFilter forcedDelegationFilter,
                        IInclExclFilter throughDelegationFilter,
                        IClassLoadHook hook,
                        java.util.Map cache)
                 throws java.net.MalformedURLException
Method Detail

loadClass

public final java.lang.Class loadClass(java.lang.String name,
                                       boolean resolve)
                                throws java.lang.ClassNotFoundException
Overrides java.lang.ClassLoader.loadClass() to change the usual parent-child delegation rules just enough to be able to 'replace' the parent loader. This also has the effect of detecting 'system' classes without doing any class name-based matching.

Throws:
java.lang.ClassNotFoundException

getResource

public final java.net.URL getResource(java.lang.String name)

findClass

protected final java.lang.Class findClass(java.lang.String name)
                                   throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

debugDump

public void debugDump(java.io.PrintWriter out)

defineClass

private java.lang.Class defineClass(java.lang.String className,
                                    byte[] bytes,
                                    int length,
                                    java.net.URL srcURL)

filesToURLs

private static java.net.URL[] filesToURLs(java.io.File[] classpath)
                                   throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

readFully

private static void readFully(java.io.InputStream in,
                              ByteArrayOStream out,
                              byte[] buf)
                       throws java.io.IOException
Reads the entire contents of a given stream into a flat byte array.

Throws:
java.io.IOException

acquirePoolEntry

private InstrClassLoader.PoolEntry acquirePoolEntry()

releasePoolEntry

private void releasePoolEntry(InstrClassLoader.PoolEntry buf)