gcj/260: "Klass.class" expression should cause Klass to be initialized
Bryce McKinlay
bryce@albatross.co.nz
Sun Jun 18 16:16: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 <jsturm@sigma6.com>
Cc: tromey@cygnus.com, apbianco@cygnus.com, java-gnats@sourceware.cygnus.com
Subject: Re: gcj/260: "Klass.class" expression should cause Klass to be
initialized
Date: Mon, 19 Jun 2000 11:10:23 +1200
Jeff Sturm wrote:
> Bryce McKinlay wrote:
> > Oh, it does. IIRC the spec is pretty clear that Class.forName() will cause
> > initialization (and JDBC wouldn't work if it didn't).
>
> I've never found that anywhere in the JLS... is there a newer copy I
> don't have? All I see is that vague explanation about "certain methods
> in java.lang.Class..."
I was actually thinking of the JDK 1.2/1.3 html docs, where it says:
"A call to forName("X") causes the class named X to be initialized."
In JDK 1.2 there is also an extended version of forName which allows you to
specifiy whether you want the class to be inititalized or not.
> > If it also says somewhere that ".class" is equivalent to Class.forName(),
> > then obviously ".class" should initialize as well.
>
> I don't know if they are intentionally equivalent, but javac supports
> the ".class" syntax by generating (indirectly) a call to
> Class.forName().
>
> Now, the PR also says "gij ClassInit" fails the test. It turns out that
> libgcj's Class.forName() fails to perform initialization as well. So
> the runtime must be patched along with gcj.
Oops, your right. I don't know how I didnt notice this before! But I see Tom
has checked in a fix for that already. gcj still needs to be fixed as well of
course, as ".class" is implemented differently.
regards
[ bryce ]
More information about the Java-prs
mailing list