public class AcsSystemClassLoader
extends java.net.URLClassLoader
The main purpose is to cut down the very long classpath produced otherwise by the ACS start scripts. Only the jar file that contains this class loader must be supplied to the JVM using the "-classpath" option. The JVM must be started with property definitions similar to:
-Djava.system.class.loader=alma.acs.classloading.AcsSystemClassLoader.
-Dacs.system.classpath.jardirs=../lib/:$INTROOT/lib:$ACSROOT/lib.
If an operating system has a native style path separator different from ":", it can optionally be used instead.
URLClassLoader.
java.system.class.loader.
sun.misc.Launcher$AppClassLoader) as the parent,
since ACS 6.0 this CL takes over the functionality of the direct parent, and uses the original grandparent CL for parent-delegation.
Circumventing the original parent CL after copying its CLASSPATH entries, removes the distinction between the CLASSPATH entries
and the jar files from the acs.system.classpath.jardirs directories.
../lib/ACScomponents are not picked up by the classloader unless we add them to the CLASSPATH,
e.g. using acsStartJava -addToClasspath.
ClassLoader.getSystemClassLoader() "tricks" the caller and returns this class loader,
even though it thinks that the real system CL is our circumvented sibling, the sun.misc.Launcher$AppClassLoader.
This allows JUnit tests run, since the JUnit framework sets up their own classloader to be a child
of the system classloader, shortcutting any "regular" child class loaders in between.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PROPERTY_CLASSLOADERVERBOSE |
static java.lang.String |
PROPERTY_JARDIRS |
static java.lang.String |
PROPERTY_TOPJARSONLY |
| Constructor and Description |
|---|
AcsSystemClassLoader(java.lang.ClassLoader parent)
Constructor will be called by the JVM.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Class<?> |
findClass(java.lang.String name)
Delegates to base class implementation.
|
protected java.lang.Class<?> |
loadClass(java.lang.String name,
boolean resolve) |
addURL, close, definePackage, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstanceclearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSignerspublic static final java.lang.String PROPERTY_JARDIRS
public static final java.lang.String PROPERTY_TOPJARSONLY
public static final java.lang.String PROPERTY_CLASSLOADERVERBOSE
public AcsSystemClassLoader(java.lang.ClassLoader parent)
sun.misc.Launcher$AppClassLoader
is expected to be the parent parameter, although no such assumption is made in the code.
In the ctor, the directories given in acs.system.classpath.jardirs are searched for JAR files,
which are fed as URLs into the classpath maintained by the URLClassLoader base class.
AcsJarFileFinderprotected java.lang.Class<?> loadClass(java.lang.String name,
boolean resolve)
throws java.lang.ClassNotFoundException
loadClass in class java.lang.ClassLoaderjava.lang.ClassNotFoundExceptionprotected java.lang.Class<?> findClass(java.lang.String name)
throws java.lang.ClassNotFoundException
Discards requests to load classes from certain sub-packages of sun. or com.sun.
by throwing a ClassNotFoundException.
The JDK libs try to search (e.g. during ACS container startup) for some optional system classes such as
sun.text.resources.DateFormatZoneData_en_US or sun.util.logging.resources.logging_en.
We know that ALMA jar files do not contain any classes in those packages, and can thus speed up the applications,
in cases where those classes have already been searched unsuccessfully by any parent class loaders,
which as the last step desparately would ask this class loader, which would cause a search through all jar files.
sun.awt.resources.
com.sun.swing.internal.plaf.
findClass in class java.net.URLClassLoaderjava.lang.ClassNotFoundException