felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r395282 - /incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
Date Wed, 19 Apr 2006 15:51:59 GMT
Author: rickhall
Date: Wed Apr 19 08:51:56 2006
New Revision: 395282

URL: http://svn.apache.org/viewcvs?rev=395282&view=rev
Log:
Found another issue in boot delegation when it comes to classes/resources
in the default package (i.e., no package name). For now, no delegation to
the parent class loader will occur if there is no package name.

Also, modified the diagnostics to use the same class loader for checking
the parent class loader as the one that is actually used for boot delegation.

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

Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java?rev=395282&r1=395281&r2=395282&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
(original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
Wed Apr 19 08:51:56 2006
@@ -304,12 +304,18 @@
             // delegated to the parent class loader. 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]) ||
-                m_bootPkgs[i].regionMatches(0, pkgName, 0, pkgName.length())))
-                || (!m_bootPkgWildcards[i] && m_bootPkgs[i].equals(pkgName)))
+            if (pkgName.length() > 0)
             {
-                return getClass().getClassLoader().loadClass(name);
+                // Only consider delegation if we have a package name, since
+                // we don't want to promote the default package. The spec does
+                // not take a stand on this issue.
+                if ((m_bootPkgWildcards[i] &&
+                    (pkgName.startsWith(m_bootPkgs[i]) ||
+                    m_bootPkgs[i].regionMatches(0, pkgName, 0, pkgName.length())))
+                    || (!m_bootPkgWildcards[i] && m_bootPkgs[i].equals(pkgName)))
+                {
+                    return getClass().getClassLoader().loadClass(name);
+                }
             }
         }
 
@@ -468,12 +474,18 @@
             // delegated to the parent class loader. 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]) ||
-                m_bootPkgs[i].regionMatches(0, pkgName, 0, pkgName.length())))
-                || (!m_bootPkgWildcards[i] && m_bootPkgs[i].equals(pkgName)))
+            if (pkgName.length() > 0)
             {
-                return getClass().getClassLoader().getResource(name);
+                // Only consider delegation if we have a package name, since
+                // we don't want to promote the default package. The spec does
+                // not take a stand on this issue.
+                if ((m_bootPkgWildcards[i] &&
+                    (pkgName.startsWith(m_bootPkgs[i]) ||
+                    m_bootPkgs[i].regionMatches(0, pkgName, 0, pkgName.length())))
+                    || (!m_bootPkgWildcards[i] && m_bootPkgs[i].equals(pkgName)))
+                {
+                    return getClass().getClassLoader().getResource(name);
+                }
             }
         }
 
@@ -1859,7 +1871,7 @@
                 boolean classpath = false;
                 try
                 {
-                    ClassLoader.getSystemClassLoader().loadClass(name);
+                    getClass().getClassLoader().loadClass(name);
                     classpath = true;
                 }
                 catch (Exception ex)
@@ -1881,7 +1893,7 @@
                 sb.append(" does export it.");
                 if (classpath)
                 {
-                    sb.append(" There are two fixes: 1) Add an import for '");
+                    sb.append(" Additionally, the class is also available from the system
class loader. There are two fixes: 1) Add an import for '");
                     sb.append(pkgName);
                     sb.append("' to bundle ");
                     sb.append(impId);
@@ -1912,7 +1924,7 @@
         {
             try
             {
-                ClassLoader.getSystemClassLoader().loadClass(name);
+                getClass().getClassLoader().loadClass(name);
 
                 exported = true;
 



Mime
View raw message