Patch to avoid SegFault in natClass.cc

Jeff Sturm jsturm@one-point.com
Mon Jul 16 05:07:00 GMT 2001


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");
  }
}



More information about the Java-patches mailing list