[
https://jira.jboss.org/jira/browse/JBCL-43?page=com.atlassian.jira.plugin...
]
Adrian Brock closed JBCL-43.
----------------------------
Resolution: Done
This has been fixed by introducing a getClassPackageInformation() to the abstract
ClassLoaderPolicy. By default it just invokes the old method.
This basically means the policy can more accurately determine the root when retrieving
the manifest information.
PackageInformation retrieved from wrong jar
-------------------------------------------
Key: JBCL-43
URL:
https://jira.jboss.org/jira/browse/JBCL-43
Project: JBoss ClassLoader
Issue Type: Bug
Components: ClassLoaderPolicy, VFS
Affects Versions: JBossCL.2.0.0.CR2
Reporter: Stan Silvert
Assignee: Adrian Brock
Fix For: JBossCL.2.0.0.GA, JBossCL.2.2.0.Alpha
Attachments: jboss-seam-numberguess.ear, patch.diff
I have an ear with these two files in the root:
jboss-seam.jar
jboss-seam-booking.jar
I want to get package info such as Implementation-Version from the class
org.jboss.seam.Seam, which is in jboss-seam.jar. However,
Seam.class.getPackage().getImplementationVersion() returns the version from the manifest
in jboss-seam-booking.jar.
I found that the problem is in VFSClassLoaderPolicy. getPackageInformation() will call
findRoot("org/jboss/seam"). But it happens to look in jboss-seam-booking.jar
first. So it finds classes with the package org.jboss.seam.booking and returns the
package info from the wrong jar.
This change to VFSClassLoaderPolicy.findVirtualFileInfo() fixes the problem:
protected VirtualFileInfo findVirtualFileInfo(String path)
{
VirtualFileInfo result = vfsCache.get(path);
if (result != null)
return result;
for (VirtualFile root : roots)
{
try
{
VirtualFile file = root.getChild(path);
if (file != null)
{
// Must either be a file...
if (file.isLeaf())
{
result = new VirtualFileInfo(file, root);
vfsCache.put(path, result);
return result;
}
// ... or have a child that is a file
for (VirtualFile child : file.getChildren())
{
if (!child.isLeaf()) continue;
result = new VirtualFileInfo(file, root);
vfsCache.put(path, result);
return result;
}
}
}
catch (Exception ignored)
{
}
}
return null;
}
I didn't want to commit this without someone else looking at it. There are two
concerns:
1) Searching all the children might have a performance impact?
2) Would this cause a problem for other code paths that use findVirtualFileInfo()?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira