public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
* RE: ClassLoader.findLoadedClass (was: ServiceFactory)
@ 2004-03-24 10:40 Robert Lougher
  2004-03-25  0:02 ` David Holmes
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Lougher @ 2004-03-24 10:40 UTC (permalink / raw)
  To: dholmes, archie; +Cc: brawer, chris, aph, classpath, mauve-discuss

Yes, I agree (but see my comment below).  Iin fact, I suggested moving 
findLoadedClass to the VMClassLoader in my last post.  The next release of 
JamVM, which should be out tonight, will have this.  This means releasing a 
modified ClassLoader as a "VM class" but it'll be a while before this makes 
it into the next release of Classpath.

Thanks,

Rob.

----Original Message Follows----
From: "David Holmes" <dholmes@dltech.com.au>

...

>VMClassLoader can define a default mechanism using hashtables or just leave
>things native.
>

A pure Java "reference" implementation won't work.  At the Java level 
VMClassLoader can only keep track of classes defined by a loader (when it 
calls VMClassLoader.defineClass). A call back will be needed so that the VM 
can record a loader as an initiating loader for a class.

>Or in simple words: move the lookup table out of ClassLoader into
>VMClassLoader.


David Holmes

_________________________________________________________________
Use MSN Messenger to send music and pics to your friends 
http://www.msn.co.uk/messenger

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: ClassLoader.findLoadedClass (was: ServiceFactory)
@ 2004-03-22 13:15 Robert Lougher
  2004-03-23  0:44 ` David Holmes
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Lougher @ 2004-03-22 13:15 UTC (permalink / raw)
  To: brawer, dholmes, chris, aph; +Cc: classpath, mauve-discuss

Interesting -- that's a documentation change between 1.3 and 1.4.  In the 
specs for 1.3 it simply says:

protected final Class findLoadedClass(String name)
"Finds the class with the given name if it had been previously loaded 
through this class loader."

Which is suitably vague enough for several interpretations.  Pragmatically, 
a class loader must keep track of the classes defined by itself so it 
doesn't try to define them again.  This appears to be 
Classpaths'interpretation.

However, as Sascha points out, 1.4's explicitly says it should return 
classes _recorded by the virtual machine_ as initiated by the loader. 
Strictly, this doesn't mean all classes initiated by the loader, just the 
ones recorded by the VM.  As I said, if loadClass is called implicitly by 
the VM it's recorded as an initiating loader, but not if loadClass is called 
explicitly by the programmer.  The JDK is therefore correct, as loadClass 
was called explicitly.

In fact, nowhere in the documentation does it say that calling loadClass on 
a class loader makes it an initiating loader of the returned class!

The bad news is that Classpath (at least 0.07) is wrong according to the new 
documentation.  It won't handle classes recorded by the VM as being 
initiated by it.  Perhaps it should be moved into the VM class, so that a VM 
can do it natively using its internal class tables?  (Alternatively, a VM 
can implement it as a call back to record it as an initiating loader).

Rob.

----Original Message Follows----
From: Sascha Brawer <brawer@dandelis.ch>
To: David Holmes <dholmes@dltech.com.au>, Chris Gray 
<chris@kiffer.eunet.be>, Andrew Haley <aph@redhat.com>, Robert Lougher 
<robert_lougher@hotmail.com>
CC: GNU Classpath <classpath@gnu.org>, <mauve-discuss@sources.redhat.com>
Subject: Re: ClassLoader.findLoadedClass (was: ServiceFactory)
Date: Mon, 22 Mar 2004 10:15:54 +0100

Robert Lougher <robert_lougher@hotmail.com> wrote on Mon, 22 Mar 2004 09:
03:12 +0000:

 >However, in the explicit case, the initiator has been lost --
 >defineClass only has the defining loader, and we don't have an "add
 >initiating loader" call for use when we unwind.  Even if findLoadedClass 
was
 >native so it could use the VM class cache, the VM wouldn't know that, 
using
 >your example, L1 initiated the load and would return null.

Does this mean that the API specification for ClassLoader.findLoadedClass
is incorrect? Or should it say that a VM may or may not record the fact that
some ClassLoader has initiated the loading of a class?

 > protected final Class findLoadedClass(String name)
 >
 >   Returns the class with the given name if this loader has been recorded
 >   by the Java virtual machine as an initiating loader of a class with
 >   that name. Otherwise null is returned.

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/
ClassLoader.html#findLoadedClass(java.lang.String)

-- Sascha

Sascha Brawer, brawer@dandelis.ch, http://www.dandelis.ch/people/brawer/

_________________________________________________________________
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo

^ permalink raw reply	[flat|nested] 8+ messages in thread
[parent not found: <NFBBKALFDCPFIDBNKAPCIEFEDPAA.dholmes@dltech.com.au>]

end of thread, other threads:[~2004-03-25  0:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-24 10:40 ClassLoader.findLoadedClass (was: ServiceFactory) Robert Lougher
2004-03-25  0:02 ` David Holmes
  -- strict thread matches above, loose matches on Subject: below --
2004-03-22 13:15 Robert Lougher
2004-03-23  0:44 ` David Holmes
2004-03-23 17:25   ` Archie Cobbs
2004-03-23 23:59     ` David Holmes
     [not found] <NFBBKALFDCPFIDBNKAPCIEFEDPAA.dholmes@dltech.com.au>
2004-03-22  8:14 ` Sascha Brawer
2004-03-22  9:16   ` Sascha Brawer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).