felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r395255 - /incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
Date Wed, 19 Apr 2006 14:43:35 GMT
Author: rickhall
Date: Wed Apr 19 07:43:32 2006
New Revision: 395255

URL: http://svn.apache.org/viewcvs?rev=395255&view=rev
Log:
Fixed a boot delegation bug with resource loading that was previously fixed
for class loading, but not copied over for resource loading...we could
investigate merging these to avoid such errors.

Also improved the dianostic error message for class loading errors that
occur with exporters available.

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=395255&r1=395254&r2=395255&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 07:43:32 2006
@@ -301,12 +301,12 @@
             // A wildcarded boot delegation package will be in the form of "foo.",
             // so if the package is wildcarded do a startsWith() or a regionMatches()
             // to ignore the trailing "." to determine if the request should be
-            // delegated to the paren class loader. If the package is not wildcarded,
+            // 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())))
+                (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);
@@ -465,12 +465,12 @@
             // A wildcarded boot delegation package will be in the form of "foo.",
             // so if the package is wildcarded do a startsWith() or a regionMatches()
             // to ignore the trailing "." to determine if the request should be
-            // delegated to the paren class loader. If the package is not wildcarded,
+            // 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, m_bootPkgs[i].length() - 1)))
+                (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);
@@ -486,7 +486,7 @@
             if (url == null)
             {
                 url = module.getContentLoader().getResource(name);
-        
+
                 // If still not found, then try the module's dynamic imports.
                 if (url == null)
                 {
@@ -1856,6 +1856,16 @@
             if (exporters.length > 0)
             {
                 exported = true;
+                boolean classpath = false;
+                try
+                {
+                    ClassLoader.getSystemClassLoader().loadClass(name);
+                    classpath = true;
+                }
+                catch (Exception ex)
+                {
+                    // Ignore
+                }
    
                 long expId = Util.getBundleIdFromModuleId(exporters[0].getId());
    
@@ -1868,16 +1878,28 @@
                 sb.append(pkgName);
                 sb.append("' even though bundle ");
                 sb.append(expId);
-                sb.append(" does export it. There are two fixes: 1) Add an import for '");
-                sb.append(pkgName);
-                sb.append("' to bundle ");
-                sb.append(impId);
-                sb.append("; imports are necessary for each class directly touched by bundle
code or indirectly touched, such as super classes if their methods are used. ");
-                sb.append("2) Add package '");
-                sb.append(pkgName);
-                sb.append("' to the '");
-                sb.append(Constants.FRAMEWORK_BOOTDELEGATION);
-                sb.append("' property; a library or VM bug can cause classes to be loaded
by the wrong class loader. The first approach is preferable for preserving modularity.");
+                sb.append(" does export it.");
+                if (classpath)
+                {
+                    sb.append(" There are two fixes: 1) Add an import for '");
+                    sb.append(pkgName);
+                    sb.append("' to bundle ");
+                    sb.append(impId);
+                    sb.append("; imports are necessary for each class directly touched by
bundle code or indirectly touched, such as super classes if their methods are used. ");
+                    sb.append("2) Add package '");
+                    sb.append(pkgName);
+                    sb.append("' to the '");
+                    sb.append(Constants.FRAMEWORK_BOOTDELEGATION);
+                    sb.append("' property; a library or VM bug can cause classes to be loaded
by the wrong class loader. The first approach is preferable for preserving modularity.");
+                }
+                else
+                {
+                    sb.append(" To resolve this issue, add an import for '");
+                    sb.append(pkgName);
+                    sb.append("' to bundle ");
+                    sb.append(impId);
+                    sb.append(".");
+                }
                 sb.append("\n****\n****");
 
                 m_logger.log(Logger.LOG_ERROR, sb.toString());



Mime
View raw message