Folks, this relates to
https://jira.jboss.org/jira/browse/JBCL-25
What I've basically done is make the generated error dependent on the the SplitPackagePolicy, which can be configured at at PackageCapability
Module otherModule = modulesByPackage.get(exportedPackage);
if (otherModule != null)
{
PackageCapability exportCapability = module.getExportCapability(exportedPackage);
if (exportCapability.getSplitPackagePolicy() == SplitPackagePolicy.Error)
{
// TODO JBCL-22 ERRORS
throw new IllegalStateException(module + " cannot be added because it is exports package " + exportedPackage + " which conflicts with " + otherModule);
}
}
There is additional code that tries to swap the module for an existing export package
// Update the exported packages
if (exportedPackages != null && exportedPackages.isEmpty() == false)
{
for (String exportedPackage : exportedPackages)
{
Module firstModule = modulesByPackage.get(exportedPackage);
PackageCapability exportCapability = module.getExportCapability(exportedPackage);
if (firstModule == null || exportCapability.getSplitPackagePolicy() == SplitPackagePolicy.Last)
modulesByPackage.put(exportedPackage, module);
}
}
This however, does not work and I'd like to get some insight on how to do this properly
The test that is supposed to verify SplitPackagePolicy.Last is here
public void testSplitPackageLast() throws Exception
{
MockClassLoadingMetaData ab = getModuleAB(null);
MockClassLoadingMetaData ac = getModuleAC(SplitPackagePolicy.Last);
KernelControllerContext contextAB = install(ab);
try
{
ClassLoader clAB = assertClassLoader(contextAB);
assertLoadClass(A.class, clAB);
assertLoadClass(B.class, clAB);
KernelControllerContext contextAC = install(ac);
ClassLoader clAC = assertClassLoader(contextAC);
System.out.println("FIXME: SplitPackagePolicy.Last");
// assertLoadClass(A.class, clAC);
assertLoadClass(B.class, clAB);
assertLoadClass(C.class, clAC);
}
finally
{
uninstall(contextAB);
}
assertNoClassLoader(contextAB);
}