gcj/260: "Klass.class" expression should cause Klass to be initialized
Bryce McKinlay
bryce@albatross.co.nz
Thu Jun 15 20:40: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: Tom Tromey <tromey@cygnus.com>
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: gcj/260: "Klass.class" expression should cause Klass to be
initialized
Date: Fri, 16 Jun 2000 15:34:41 +1200
Tom Tromey wrote:
> Bryce> Using .class syntax should cause the referenced class to
> Bryce> be initialized.
>
> Is this really an active use of the class? Do you have a reference?
> I didn't see this in the 1.2 JVM spec.
I didn't find any reference in the spec either (but I didn't look very
hard). It does say that "certain reflective methods" will cause
initialization, so I guess ".class" could fall into that category.
I tried the test case on 3 different VMs (1.1.8, 1.2.2, and 1.3), and
they will all initialize the class just by assigning a java.lang.Class
variable from a ".class" expression.
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)
regards
[b ryce ]
More information about the Java-prs
mailing list