[jboss-cvs] JBossAS SVN: r106044 - projects/jboss-cl/branches/jbosgi342/classloading/src/main/java/org/jboss/classloading/spi/dependency.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jun 15 01:41:57 EDT 2010


Author: thomas.diesler at jboss.com
Date: 2010-06-15 01:41:56 -0400 (Tue, 15 Jun 2010)
New Revision: 106044

Modified:
   projects/jboss-cl/branches/jbosgi342/classloading/src/main/java/org/jboss/classloading/spi/dependency/Domain.java
Log:
Skip module resolution for dynamic non-optional requirements against capabilities that come from the same module as the dynamic requirement


Modified: projects/jboss-cl/branches/jbosgi342/classloading/src/main/java/org/jboss/classloading/spi/dependency/Domain.java
===================================================================
--- projects/jboss-cl/branches/jbosgi342/classloading/src/main/java/org/jboss/classloading/spi/dependency/Domain.java	2010-06-15 05:39:58 UTC (rev 106043)
+++ projects/jboss-cl/branches/jbosgi342/classloading/src/main/java/org/jboss/classloading/spi/dependency/Domain.java	2010-06-15 05:41:56 UTC (rev 106044)
@@ -173,9 +173,9 @@
       {
          removeModule(module);
          if (t instanceof RuntimeException)
-            throw (RuntimeException) t;
+            throw (RuntimeException)t;
          else if (t instanceof Error)
-            throw (Error) t;
+            throw (Error)t;
          else
             throw new RuntimeException("Error adding module " + module, t);
       }
@@ -299,9 +299,15 @@
             return result;
       }
 
-      Module firstMatch = null;
+      Module result = null;
+      Capability firstMatch = null;
+      
       for (Module other : modules)
       {
+         // A dynamic import cannot resolve against the same module that requires the import
+         if (requirement.isDynamic() && requirement.isOptional() == false && module == other)
+            continue;
+         
          List<Capability> capabilities = other.getCapabilities();
          if (capabilities != null)
          {
@@ -309,21 +315,22 @@
             {
                if (capability.resolves(module, requirement))
                {
-                  if (firstMatch != null)
+                  if (firstMatch != null && other != result)
                   {
-                     String otherName = other.getName() + ":" + other.getVersion();
-                     String firstName = firstMatch.getName() + ":" + firstMatch.getVersion();
-                     log.debug("Requirement " + requirement + " resolves agaist " + firstName + " and " + otherName + " - using first.");
+                     log.debug("Requirement " + requirement + " resolves agaist " + firstMatch + " and " + capability + " - using first.");
                   }
-                  if (firstMatch == null)
-                     firstMatch = other;
+                  if (result == null)
+                  {
+                     firstMatch = capability;
+                     result = other;
+                  }
                }
             }
          }
       }
 
-      if (firstMatch != null)
-         return firstMatch;
+      if (result != null)
+         return result;
 
       // Check the parent afterwards when required
       if (parentDomain != null && parentFirst == false)
@@ -414,7 +421,7 @@
                Requirement requirement = dependencyItem.getRequirement();
                if (requirement instanceof ModuleRequirement && dependencyItem.isResolved())
                {
-                  ModuleRequirement moduleRequirement = (ModuleRequirement) requirement;
+                  ModuleRequirement moduleRequirement = (ModuleRequirement)requirement;
                   if (name == null || name.equals(moduleRequirement.getName()))
                   {
                      if (range.isConsistent(moduleRequirement.getVersionRange()))
@@ -469,7 +476,7 @@
             {
                if (capability instanceof PackageCapability && capability.resolves(module, requirement))
                {
-                  ExportPackage exportPackage = new ExportPackage(module, (PackageCapability) capability);
+                  ExportPackage exportPackage = new ExportPackage(module, (PackageCapability)capability);
                   result.add(exportPackage);
                   break;
                }



More information about the jboss-cvs-commits mailing list