You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/02/13 16:26:04 UTC

svn commit: r744144 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java

Author: rickhall
Date: Fri Feb 13 15:25:50 2009
New Revision: 744144

URL: http://svn.apache.org/viewvc?rev=744144&view=rev
Log:
Properly fixed boot delegation. (FELIX-934)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java?rev=744144&r1=744143&r2=744144&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java Fri Feb 13 15:25:50 2009
@@ -1270,18 +1270,31 @@
         {
             for (int i = 0; !result && (i < m_bootPkgs.length); i++)
             {
-                // A wildcarded boot delegation package will be in the form of "foo.",
-                // so if the package is wildcarded do a startsWith() to check for
-                // subpackages or a regionMatches() to check for an exact match
-                // without the trailing ".". If the package is not wildcarded,
-                // then simply do an equals() test to see if the request should be
-                // delegated to the parent class loader.
-                if ((m_bootPkgWildcards[i] &&
-                    (pkgName.startsWith(m_bootPkgs[i]) ||
-                    pkgName.regionMatches(0, m_bootPkgs[i], 0, m_bootPkgs[i].length() - 1)))
-                    || (!m_bootPkgWildcards[i] && m_bootPkgs[i].equals(pkgName)))
+                // Check if the boot package is wildcarded.
+                if (m_bootPkgWildcards[i])
                 {
-                    result = true;
+                    // A wildcarded boot package will be in the form "foo.",
+                    // so a matching subpackage will start with "foo.", e.g.,
+                    // "foo.bar".
+                    if (pkgName.startsWith(m_bootPkgs[i]))
+                    {
+                        return true;
+                    }
+                    // If we have "foo." as our wildcarded boot package, then
+                    // the package "foo" should be delegated too, but we don't
+                    // want to delegate "foobar", so we check to make sure the
+                    // package names are the same length and then perform a
+                    // region match to ignore the "." on "foo.".
+                    else if ((pkgName.length() == m_bootPkgs[i].length() - 1)
+                        && pkgName.regionMatches(0, m_bootPkgs[i], 0, m_bootPkgs[i].length() - 1))
+                    {
+                        return true;
+                    }
+                }
+                // If not wildcarded, then check for an exact match.
+                else if (m_bootPkgs[i].equals(pkgName))
+                {
+                    return true;
                 }
             }
         }