RFR (M) 8061651 - Interface to the Lookup Index Cache to improve URLClassPath search time (round 3)
Ioi Lam
ioi.lam at oracle.com
Tue Oct 28 04:57:55 UTC 2014
On 10/27/14, 7:52 PM, Jiangli Zhou wrote:
> Hi Ioi,
>
> I have a question for following code in AppClassLoader.loadClass(). If
> a class is 'known to not exist' for the AppClassLoader (not in the
> AppClassLoader and parent classloaders' shared lookup cache), it seems
> findLoadedClass() would only find classes that's dynamically loaded by
> the parent loaders. The AppClassLoader would never try to load the
> class. Is the AppClassLoader's lookup cache guaranteed to have all the
> classes in it's path?
>
> 315 if (ucp.knownToNotExist(name)) {
> 316 // The class of the given name is not found in
> the parent
> 317 // class loader as well as its local URLClassPath.
> 318 // Check if this class has already been defined
> dynamically;
> 319 // if so, return the loaded class; otherwise,
> skip the parent
> 320 // delegation and findClass.
> 321 synchronized (getClassLoadingLock(name)) {
> 322 Class<?> c = findLoadedClass(name);
> 323 if (c != null) {
> 324 return c;
> 325 }
> 326 }
> 327 throw new ClassNotFoundException(name);
> 328 }
The reason is to make the behavior consistent with
java.lang.ClassLoader.loadClass():
protected Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
synchronized (getClassLoadingLock(name)) {
// First, check if the class has already been loaded
Class<?> c = findLoadedClass(name);
....
If <name> is not in any of the JAR files but was dynamically defined
(using ClassLoader.defineClass, etc), then AppClassLoader.loadClass()
should return the class without throwing ClassNotFoundException.
Thanks
- Ioi
> Thanks,
> Jiangli
>
> On 10/27/2014 3:32 PM, Ioi Lam wrote:
>> Hi David, I have update the latest webrev at:
>>
>> http://cr.openjdk.java.net/~iklam/8061651-lookup-index-open-v3/
>>
>> and fixed the "int cache[]" style you mentioned.
>>
>> This version also contains the JDK test case that Mandy requested:
>>
>> http://cr.openjdk.java.net/~iklam/8061651-lookup-index-open-v3/jdk/test/sun/misc/URLClassPath/EnableLookupCache.java.html
>>
>>
>> Thanks
>> - Ioi
>>
More information about the core-libs-dev
mailing list