🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1358

Re: Changing the default class loader.

#1358
From: John McGrath TeamB
Date: Wed, 30 Jan 2002 22:27
35 lines
2324 bytes
On Mon, 28 Jan 2002 10:05:14 +0200, Hanan Hermon wrote:

> I want the system to use my ClassLoader, instead of the default
> defined for it.

You cannot change this behavior.  If you could, you would break all of 
the Java security mechanisms.  When a class is referenced from within 
another class, it will use the ClassLoader for that class to load the 
new class, and each ClassLoader is supposed to first defer to its 
parent ClassLoader.  

Since the system classes were loaded by the system ClassLoader, any 
classes that those classes require will also be loaded by the system 
ClassLoader.  Your ClassLoader will not be called.

When you use your ClassLoader to explicitly load a class, classes that 
it requires will be loaded with your ClassLoader.  It should call the 
parent ClassLoader before trying to load the class, so system classes 
will still be loaded by the system ClassLoader.

However, note that even if your ClassLoader violates this rule and 
loads a system class itself (say java.lang.Integer), that class will 
be distinct from the normal java.lang.Integer class, since the identity 
of a class includes the ClassLoader that loaded it.  The system classes 
will continue to use the java.lang.Integer class that was loaded by the 
system ClassLoader.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <MPG.16c23d28b73e04fb98b245@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!news.boerde.de!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!dnews
References: <3c550667$1_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,144532415003ca26
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2002-01-30 14:33:15 PST
From: John McGrath  [TeamB] <ng-b@JPMcGrath.net>
Newsgroups: borland.public.jbuilder.java.api
Subject: Re: Changing the default class loader.
Date: Wed, 30 Jan 2002 17:27:09 -0500
Message-ID: <MPG.16c23d28b73e04fb98b245@newsgroups.borland.com>
References: <3c550667$1_2@dnews>
X-Newsreader: MicroPlanet Gravity v2.60
NNTP-Posting-Host: 209.92.40.60
X-Trace: dnews 1012429628 209.92.40.60 (30 Jan 2002 14:27:08 -0800)
Lines: 35
X-Authenticated-User: jpmcgrath
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!news.boerde.de!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!dnews