gcj/260: "Klass.class" expression should cause Klass to be initialized

Bryce McKinlay bryce@albatross.co.nz
Sun Jun 18 05:00:00 GMT 2000


The following reply was made to PR gcj/260; it has been noted by GNATS.

From: Bryce McKinlay <bryce@albatross.co.nz>
To: Jeff Sturm <jeff.sturm@appnet.com>
Cc: apbianco@cygnus.com, java-gnats@sourceware.cygnus.com
Subject: Re: gcj/260: "Klass.class" expression should cause Klass to be 
 initialized
Date: Sun, 18 Jun 2000 23:59:06 +1200

 Jeff Sturm wrote:
 
 > The Microsoft VM does not initialize such a class (or didn't, it may
 > have changed by now).  That used to break a lot of code to initialize
 > JDBC:
 >
 > Class.forName("sun.jdbc.odbc.JdbcOdbcBridge");
 >
 > which became a no-op on the MS VM (Class.forName is equivalent to the
 > .class syntax, except that latter never throws an exception).
 >
 > >  It should make things slightly more efficient if we have the compiler
 > >  doing the initialization, since it can remove redundant initialization
 > >  calls within the same method (and we can remove several initialozation
 > >  calls from reflective methods in natClass.cc)
 >
 > I agree.  It will also help to avoid certain incompatibilities.  I don't
 > remember if libgcj Class.forName also initializes a class, but it should
 > for compatibility with JDK.
 
 Oh, it does. IIRC the spec is pretty clear that Class.forName() will cause
 initialization (and JDBC wouldn't work if it didn't). If it also says
 somewhere that ".class" is equivalent to Class.forName(), then obviously
 ".class" should initialize as well.
 
 regards
 
   [ bryce ]
 
 


More information about the Java-prs mailing list