coolness

Jeff Sturm jsturm@sigma6.com
Fri Mar 12 08:56:00 GMT 1999


Tom Tromey wrote:
> 
> >>>>> "Jeff" == Jeff Sturm <jsturm@sigma6.com> writes:
> 
> Jeff> What needs to work in gcj is Class.forName("...") which is
> Jeff> scattered all over in most java code, including the Sun java.*
> Jeff> classes, and most JDBC programs (consider how JDBC drivers are
> Jeff> loaded dynamically).
> 
> When you write this, do you mean that it is a common idiom to pass a
> constant string to Class.forName()?  (I'm afraid most of the Java code
> I've read is code written here.)

Yes.  Sometimes it is useful to get a reference to some class before any
instances are created:

  try {
    Class objClass = Class.forName("java.lang.Object");
  } catch (ClassNotFoundException ex) {
    ...
  }

In 1.1 javac introduced a new syntax:

  Class objClass = java.lang.Object.class;

but javac still generates a call to Class.forName(...) in the bytecode. 
The new syntax is just a compiler trick, not a VM feature.

> Jeff> So gcj either needs some way to statically link together all the
> Jeff> classes it will eventually need, whether or not they are
> Jeff> initially referenced, or dynamic loading via dlopen/dlsym/etc.
> Jeff> (Obviously dynamic loading is preferred...)
> 
> I agree we need to do this.  I just don't think it will be in the
> initial release.  Implementing dynamic loading should be pretty easy;
> we just don't have the time.

Fair enough.  The sooner you can get us a developer's release, the
better...

-- 
Jeff Sturm
jsturm@sigma6.com


More information about the Java mailing list