https://bz.apache.org/bugzilla/show_bug.cgi?id=61810

--- Comment #7 from Huxing Zhang <huxing.zh...@gmail.com> ---
(In reply to Konstantin Kolinko from comment #5)
> 1. Overall it looks OK.
> You must update documentation as well
> http://tomcat.apache.org/tomcat-7.0-doc/config/loader.html

Right, it is on my TODO list.

> 
> 2. FYI: See also bug 52448. Its idea is to scan the jars and cache their
> indexes, to reopen only those jars that contain the class that is to be
> loaded.


Yes, actually I would like to propose a similar enhancement after finishing
this, that is instead of reopen all the jars, we could just open the specific
jar if we know that where the class/resource is located.

During startup, Tomcat scans the jars for annotations, at this time, class are
loaded as resource, but  not defined, therefore MANIFEST.MF are not required.

However, when a class is loaded during runtime, MANIFEST.MF is required
according to JVM spec. If the jars are closed, we have to open all the jars to
find the class. This logic can be found within
org.apache.catalina.loader.WebappClassLoaderBase#findResourceInternal(java.lang.String,
java.lang.String, boolean):

        ResourceEntry entry = resourceEntries.get(path);
        if (entry != null) {
            if (manifestRequired && entry.manifest == MANIFEST_UNKNOWN) {
                // This resource was added to the cache when a request was made
                // for the resource that did not need the manifest. Now the
                // manifest is required, the cache entry needs to be updated.
                synchronized (jarFiles) {
                    if (openJARs()) {
                        ...
                     }
                }
            }
            return entry;
        }

If we can record which jar is a class is loaded (as resource) from, we can just
open that specific jar file instead of all jars.

This will be very helpful when a class is scanned before and being loaded for
the first time.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to