classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: A query on the classloader architecture


From: David Holmes
Subject: RE: A query on the classloader architecture
Date: Mon, 12 Jul 2004 08:57:04 +1000

Chris Gray wrote:
> Why do you think people write stuff like
>    Class c;
>    ClassLoader cl = this.getClass().getClassLoader();
>    if (cl == null) {
>      c = Class.forName(classname);
>    }
>    else {
>      c = Class.forName(classname, false, cl);
>    }
>
> Which gets tedious, real fast. :-{

Hmmm. Given that the *only* distinction between the two forms of forName are
that the first implies initialize=true while the latter gives
initialize=false, I don't know why anyone would write that code. ???

Class.forName(className) is "equivalent to:
  Class.forName(className, true, currentLoader)
where currentLoader denotes the defining class loader of the current class."

David Holmes





reply via email to

[Prev in Thread] Current Thread [Next in Thread]