Properly fixed boot delegation. (FELIX-934)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@744144 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java b/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
index 63f48a7..a82452e 100644
--- a/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
@@ -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;
                 }
             }
         }