From cd2518594b532c0b0633562220f226bfc6e58f06 Mon Sep 17 00:00:00 2001 From: Simon Kitching Date: Tue, 25 Jul 2006 01:26:37 +0000 Subject: [PATCH] Add javadoc about setExplicitLoader/addLogicalLib. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@425247 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/logging/PathableClassLoader.java | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/test/org/apache/commons/logging/PathableClassLoader.java b/src/test/org/apache/commons/logging/PathableClassLoader.java index 3c80cb5..f2c3a3b 100644 --- a/src/test/org/apache/commons/logging/PathableClassLoader.java +++ b/src/test/org/apache/commons/logging/PathableClassLoader.java @@ -72,9 +72,27 @@ public class PathableClassLoader extends URLClassLoader { * See setParentFirst. */ private boolean parentFirst = true; - + /** * Constructor. + *

+ * Often, null is passed as the parent, ie the parent of the new + * instance is the bootloader. This ensures that the classpath is + * totally clean; nothing but the standard java library will be + * present. + *

+ * When using a null parent classloader with a junit testcase, it *is* + * necessary for the junit library to also be visible. In this case, it + * is recommended that the following code be used: + *

+     * pathableLoader.useExplicitLoader(
+     *   "junit.",
+     *   junit.framework.Test.class.getClassLoader());
+     * 
+ * Note that this works regardless of whether junit is on the system + * classpath, or whether it has been loaded by some test framework that + * creates its own classloader to run unit tests in (eg maven2's + * Surefire plugin). */ public PathableClassLoader(ClassLoader parent) { super(NO_URLS, parent); @@ -125,6 +143,28 @@ public class PathableClassLoader extends URLClassLoader { /** * Specify a classloader to use for specific java packages. + *

+ * The specified classloader is normally a loader that is NOT + * an ancestor of this classloader. In particular, this loader + * may have the bootloader as its parent, but be configured to + * see specific other classes (eg the junit library loaded + * via the system classloader). + *

+ * The differences between using this method, and using + * addLogicalLib are: + *

*/ public void useExplicitLoader(String prefix, ClassLoader loader) { if (lookasides == null) {