[jboss-jira] [JBoss JIRA] Resolved: (JBCL-115) Module adds invalid delegates
Thomas Diesler (JIRA)
jira-events at lists.jboss.org
Mon Sep 14 04:28:23 EDT 2009
[ https://jira.jboss.org/jira/browse/JBCL-115?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Diesler resolved JBCL-115.
---------------------------------
Resolution: Done
Done
I changed the code such that it adds FilteredDelegateLoaders
// Only add a the delegate if this is not a self-dependency
if (iDependOnModule != module)
{
// If we are connecting to another module we collect the imported package names per delegate
if (requirement instanceof PackageRequirement)
{
ClassLoaderPolicy policy = delegate.getPolicy();
List<String> packageNames = delegateToRequiredPackages.get(policy);
if (packageNames == null)
{
packageNames = new ArrayList<String>();
delegateToRequiredPackages.put(policy, packageNames);
}
PackageRequirement packageRequirement = (PackageRequirement)requirement;
packageNames.add(packageRequirement.getName());
}
else
{
delegates.add(delegate);
}
}
// Add FilteredDelegateLoaders for all collected package requirements
for (Entry<ClassLoaderPolicy, List<String>> entry : delegateToRequiredPackages.entrySet())
{
PackageClassFilter filter = PackageClassFilter.createPackageClassFilter(entry.getValue());
delegates.add(new FilteredDelegateLoader(entry.getKey(), filter));
}
For this I needed to change the visibility of DelegateLoader.getPolicy() to public
> Module adds invalid delegates
> -----------------------------
>
> Key: JBCL-115
> URL: https://jira.jboss.org/jira/browse/JBCL-115
> Project: JBoss ClassLoader
> Issue Type: Bug
> Reporter: Thomas Diesler
> Fix For: JBossCL.2.0.7.GA
>
>
> Consider this use case
> ExportImportPackageUnitTestCase.testSelfImportPackage
> //Bundle-Name: BundleB
> //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
> //Export-Package: org.jboss.test.osgi.classloader.support.b
> //Import-Package: org.jboss.test.osgi.classloader.support.a
> //Bundle-Name: BundleA
> //Bundle-Version: 1.0.0
> //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleA
> //Export-Package: org.jboss.test.osgi.classloader.support.a, org.jboss.test.osgi.classloader.support.b
> //Import-Package: org.jboss.test.osgi.classloader.support.a, org.jboss.test.osgi.classloader.support.b
> BundleB imports PackageA from BundleA, but *not* PackageB.
> Classes in PackageB are expected to get loaded from the bundle that the class load is initiated from.
> bundleB.start();
> assertEquals("Bundle ACTIVE", Bundle.ACTIVE, bundleB.getState());
>
> // BundleA is expected to resolve when BundleB gets started
> assertEquals("Bundle RESOLVED", Bundle.RESOLVED, bundleA.getState());
> assertLoadClass(bundleA, A.class, bundleA);
> assertLoadClass(bundleA, B.class, bundleA);
> // BundleB imports A from BundleA
> assertLoadClass(bundleB, A.class, bundleA);
>
> // BundleB does not import B
> assertLoadClass(bundleB, B.class, bundleB);
> ---------------------
> The code in Module.addDelegates(...) incorrectly adds the DelegateLoader from the dependent module irrespectively of the packages that are actually being imported. this effectively makes makes all the packages from BundleA visible to BundleB
> Module other = item.getModule();
> DelegateLoader delegate = iDependOnModule.getDelegateLoader(other, requirement);
> // Check for re-export by the module
> if (requirement.wantReExports())
> addDelegates(iDependOnModule, delegates, dynamic, visited, true);
>
> // We want a module's re-exports (i.e. part of its imports) before the module itself
> if (delegate != null)
> delegates.add(delegate);
--
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
More information about the jboss-jira
mailing list