Godmar Back wrote,
> Miles Sabin wrote,
> > [snip: className.class vs Class.forName("className")]
>
> In other words, you're saving a try/catch clause at the
> expense of one hidden static variable.
Hmm ... well, a litte more than that. The lookup is done
only once (to initialize the static).
Still, I have to admit I was a bit surprised at the
generated bytecode. I'd assumed that the constant pool
would contain a reference to the class which would be resolved directly by
the JVM at load time, rather by
code at the first point of use.
Is this just a compiler artefact (I've checked both
jikes and javac from 1.2.2) or is there some intrinsic
reason why it has to be done this way? I haven't been
able to find anything obvious that bears on this in
either the JLS or the JVM spec. I suppose it might allow
some class loading to be deferred or eliminated ... is
that the rationale?
Cheers,
Miles
--
Miles Sabin Cromwell Media
Internet Systems Architect 5/6 Glenthorne Mews
+44 (0)181 410 2230 London, W6 0LJ
[EMAIL PROTECTED] England
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]