This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch to avoid SegFault in natClass.cc
- To: Martin Kahlert <martin dot kahlert at infineon dot com>
- Subject: Re: Patch to avoid SegFault in natClass.cc
- From: Jeff Sturm <jsturm at one-point dot com>
- Date: Mon, 16 Jul 2001 08:08:47 -0400 (EDT)
- cc: java-patches at gcc dot gnu dot org, apbianco at cygnus dot com, java at gcc dot gnu dot org
On Mon, 16 Jul 2001, Martin Kahlert wrote:
> Can you tell me, what i have to do in order to get an uninitialized
> class for an instanceof test?
See the test case at the end of this message. With the JDK it will print:
Initialized
true
Class B is uninitialized prior to the instanceof operator. Note that
libgcj gets this wrong without your patch.
> Is there a deeper reason at all, why the classloader should be allowed
> to return an uninitialized class? If not, the _Jv_InitClass would be
> superflous.
That's just how Java classloaders work. It is described extensively
(if not exactly) in the JLS.
public class A {
static B b;
public static void main(String[] args) {
System.out.println(b instanceof B);
}
}
class B {
static {
System.out.println("Initialized");
}
}