On Dec 4, 2008, at 9:23 AM, Roberto Chinnici wrote:
> Paul,
>
> Section EE.8.2.5 of the platform spec contains a code snippet
> showing how to load a class dynamically.
> This snippet was updated in the Java EE 6 spec (Early Draft)
> following some experiments I ran with different OSGi implementations.
> For your convenience, here's the code:
>
> Helper method:
>
> public ClassLoader getContextClassLoader() {
> return AccessController.doPrivileged(
> new PrivilegedAction<ClassLoader>() {
> public ClassLoader run() {
> ClassLoader cl = null;
> try {
> cl =
> Thread.currentThread().getContextClassLoader();
> } catch (SecurityException ex) { }
> return cl;
> }
> });
> }
>
> Code snippet to be used by libraries:
>
> ClassLoader cl = getContextClassLoader();
> if (cl != null) {
> try {
> clazz = Class.forName(name, false, cl);
^
|
Why is this
"false" ?
Paul.