Eager vs Lazy resolution of classes
Andrew Haley
aph@redhat.com
Wed Jul 21 17:58:00 GMT 2004
Bryce McKinlay writes:
> The following test case creates a class on the fly in the classpath and
> then tries to call into that class statically, as opposed to via
> Class.forName() or some other classloader based mechanism.
>
> On Sun's 1.5 beta JVM, I get:
>
> $ rm Bar.class
> $ java Resolve
> start
> 99
> hello!!
Thanks, this is a fascinating bit of code. I would have guessed that
class verification of Resolve would fail, but now I see that access to
static fields in a class doesn't require that class to be loaded -- if
there is no field of that type, it will not be found.
As to whether we need to be compatible with this: IMO even if we don't
implement lazy linkage this kind around, we should at least design the
ABI so that it's possible.
Andrew.
More information about the Java
mailing list