public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Robert Lougher" <robert_lougher@hotmail.com>
To: brawer@dandelis.ch, dholmes@dltech.com.au, chris@kiffer.eunet.be,
	aph@redhat.com
Cc: classpath@gnu.org, mauve-discuss@sources.redhat.com
Subject: Re: ClassLoader.findLoadedClass (was: ServiceFactory)
Date: Mon, 22 Mar 2004 13:15:00 -0000	[thread overview]
Message-ID: <BAY10-F21tKrUV0hCLw0000847e@hotmail.com> (raw)

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

             reply	other threads:[~2004-03-22 13:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-22 13:15 Robert Lougher [this message]
2004-03-23  0:44 ` David Holmes
2004-03-23 17:25   ` Archie Cobbs
2004-03-23 23:59     ` David Holmes
  -- strict thread matches above, loose matches on Subject: below --
2004-03-24 10:40 Robert Lougher
2004-03-25  0:02 ` David Holmes
     [not found] <NFBBKALFDCPFIDBNKAPCIEFEDPAA.dholmes@dltech.com.au>
2004-03-22  8:14 ` Sascha Brawer
2004-03-22  9:16   ` Sascha Brawer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BAY10-F21tKrUV0hCLw0000847e@hotmail.com \
    --to=robert_lougher@hotmail.com \
    --cc=aph@redhat.com \
    --cc=brawer@dandelis.ch \
    --cc=chris@kiffer.eunet.be \
    --cc=classpath@gnu.org \
    --cc=dholmes@dltech.com.au \
    --cc=mauve-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).