this(null);
}
+ /**
+ * Creates a root class pool. If <code>useDefaultPath</code> is
+ * true, <code>appendSystemPath()</code> is called. Otherwise,
+ * this constructor is equivalent to the constructor taking no
+ * parameter.
+ *
+ * @param useDefaultPath true if the system search path is
+ * appended.
+ */
+ public ClassPool(boolean useDefaultPath) {
+ this(null);
+ if (useDefaultPath)
+ appendSystemPath();
+ }
+
/**
* Creates a class pool.
*
Java bytecode is stored in a binary file called a class file.
Each class file contains one Java class or interface.
-<p>The class <code>Javassist.CtClass</code> is an abstract
+<p>The class <code>Javassist.CtClass</code> is an absatract
representation of a class file. A <code>CtClass</code> (compile-time
class) object is a handle for dealing with a class file. The
following program is a very simple example:
code snippet:
<ul><pre>
-ClassPool cp = new ClassPool();
-cp.appendSystemPath(); // or append another path by appendClassPath()
+ClassPool cp = new ClassPool(true);
+// if needed, append an extra search path by appendClassPath()
</pre></ul>
<p>This creates a <code>ClassPool</code> object that behaves as the
does not have a special role. <code>getDefault()</code> is a convenience
method.
+<p>Note that <code>new ClassPool(true)</code> is a convenient constructor,
+which constructs a <code>ClassPool</code> object and appends the system
+search path to it. Calling that constructor is
+equivalent to the following code:
+
+<ul><pre>
+ClassPool cp = new ClassPool();
+cp.appendSystemPath(); // or append another path by appendClassPath()
+</pre></ul>
-<h4>Cascaded ClassPools.</h4>
+<h4>Cascaded ClassPools</h4>
<p>
<em>If a program is running on a web application server,</em>
snippet (this code was already <a href="#avoidmemory">shown above</a>):
<ul><pre>
-ClassPool cp = new ClassPool();
-cp.appendSystemPath(); // or append another path by appendClassPath()
+ClassPool cp = new ClassPool(true);
</pre></ul>
<p>If you have two <code>ClassPool</code> objects, then you can