Class.forName() bug?

Per Bothner bothner at cygnus.com
Mon Mar 31 13:51:33 PST 1997


> In kaffe 0.8.3, it seems that Class.forName() doesn't run the static
> initializers of the class it finds.

It is not supposed to.  The JDK 1.1 API docs say:

  public static Class forName(String className) throws ClassNotFoundException
	Returns the Class object associated with the class with the given
	String name. Given the fully-qualified name for a class or interface,
	this method attempts to locate, load and link the class.

Note that forName is not supposed to initialize the class.

> A particular consequence of this is that Sun's recommended idiom for
> making sure that a particular JDBC driver will be loaded, viz.,

Complain to Sun.  Class.forName clearly is not supposed to run the
initializers, according to Sun's language specification.  If you can
get Sun's language lawyers to agree that the specification is wrong,
we should change Kaffe.  If Sun's implementation of forName initializes
the class, then their implementation does not match their specification,
and we should complain.  If you can verify this, I have some contacts
at JavaSoft.

	--Per Bothner
Cygnus Solutions     bothner at cygnus.com     http://www.cygnus.com/~bothner



More information about the kaffe mailing list