This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch to avoid SegFault in natClass.cc




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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]