Better error reporting when loading bundle classes using Bundle.loadClass. We now let the exception from ModuleImpl.loadClass bubble up instead of swallowing it. (FELIX-674).

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@687384 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index dc40d8f..ba0caf3 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -1522,12 +1522,7 @@
                 throw new ClassNotFoundException(name);
             }
         }
-        Class clazz = bundle.getInfo().getCurrentModule().getClass(name);
-        if (clazz == null)
-        {
-            throw new ClassNotFoundException(name);
-        }
-        return clazz;
+        return bundle.getInfo().getCurrentModule().getClass(name);
     }
 
     /**
@@ -2937,7 +2932,14 @@
                 }
             }
         }
-        return (getInfo().getCurrentModule().getClass(clazz.getName()) == clazz) ? this : null;
+        try 
+        {
+            return (getInfo().getCurrentModule().getClass(clazz.getName()) == clazz) ? this : null;
+        }
+        catch(ClassNotFoundException ex) 
+        {
+            return null;
+        }
     }
 
     /**
@@ -3549,12 +3551,16 @@
             if (className != null)
             {
                 className = className.trim();
-                Class clazz = info.getCurrentModule().getClass(className);
-                if (clazz == null)
+                Class clazz;
+                try 
                 {
-                    throw new BundleException("Not found: "
-                        + className, new ClassNotFoundException(className));
+                    clazz = info.getCurrentModule().getClass(className);
                 }
+                catch (ClassNotFoundException ex) {
+                    throw new BundleException("Not found: "
+                        + className, ex);
+                }
+
                 activator = (BundleActivator) clazz.newInstance();
             }
         }
diff --git a/framework/src/main/java/org/apache/felix/moduleloader/IModule.java b/framework/src/main/java/org/apache/felix/moduleloader/IModule.java
index 5987ac8..d89898b 100644
--- a/framework/src/main/java/org/apache/felix/moduleloader/IModule.java
+++ b/framework/src/main/java/org/apache/felix/moduleloader/IModule.java
@@ -30,7 +30,7 @@
 
     public boolean isRemovalPending();
 
-    public Class getClass(String name);
+    public Class getClass(String name) throws ClassNotFoundException;
     public URL getResource(String name);
     public Enumeration getResources(String name);
 }
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java b/framework/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java
index 43757a2..7074a86 100644
--- a/framework/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java
+++ b/framework/src/main/java/org/apache/felix/moduleloader/ModuleImpl.java
@@ -172,7 +172,7 @@
         m_removalPending = removalPending;
     }
 
-    public Class getClass(String name)
+    public Class getClass(String name) throws ClassNotFoundException
     {
         try
         {
@@ -184,8 +184,8 @@
                 Logger.LOG_WARNING,
                 ex.getMessage(),
                 ex);
+            throw ex;
         }
-        return null;
     }
 
     public URL getResource(String name)