[2393] in java-interest

home help back first fref pref prev next nref lref last post

Re: More class loader info.

daemon@ATHENA.MIT.EDU (Chuck McManis)
Sat Sep 30 07:53:48 1995

Date: Thu, 28 Sep 1995 10:32:40 -0700
From: cmcmanis@scndprsn@sun.com (Chuck McManis)
To: perry@cdt.luth.se
Cc: java-interest@java@sun.com


>If I subclass awt.Window for example and load that subclass with my class
>loader, how will that class behave?

Well it depends. When you load your subclass, the resolving of that class
will request that the superclass be loaded as well. If your class loader
has its own copy of the superclass that it is handing out then this will
be percieved as distinct from the one that was loaded in the system.

>I have actually tried it and I can not access any of awt.Window's
>instance variables or methods via the subclass. However, inside the
>subclass I have normal access to them. I think that is strange.

Not really, because what is happening is that there are two superclasses
in the system the one on the "system" side and the one that your class
loader loaded. If you try to access the instance variables from the
system side they don't exist because they superclass of your subclass
appears to be different that the awt.Window class. On the otherhand inside
the subclass the references to the super class refer to the class on the
custom class loader side so they work. 

>Another strange thing is that, when I put a call to my subclass'
>inherited drawString() in my code, the program crashed with a SIGSEGV
>at the point where the subclass object is created, not at the point
>where the call is made.

Now that is probably a bug. Can you send a small test case ?  The part
that is ambiguous here is this:

Was your subclass loaded by the system class loader, or the custom
class loader? I "your code" (referred to as "my code" above) loaded
by the system loader or the custom loader? When the program crashed,
did is crash at the line 'new ...' or was the method you invoked
a static method? Does your class loader resolve the classes it loads?

>Does this mean that to subclass awt.Window for example, and be able to
>use the graphical methods of awt.Window, I will have to put a wrapper
>inside the subclass for every such method?

No, it means we have to figure out what is going on :-) 

>This seems odd. Please explain it further.

I agree with that.

--Chuck
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post