1 Reply Latest reply on Aug 25, 2009 11:33 AM by adrian.brock

    Added initial support for split packages

    thomas.diesler

      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);
       }
      



        • 1. Re: Added initial support for split packages

          I don't really understand what you are trying to do?

          The LAST policy is certainly non-deterministic since it means the
          used version of a package could change at random based on what gets deployed when.

          That would break all the consistency checking.

          The idea of split packages is that two modules can provide the same exported package
          but only if they are at the same version. The importing module should then import BOTH
          (in some deterministic order - e.g. first deployed is the first to be used).

          The validation of the ClassLoaderSpace should not treat this as an error (which it currently does).