Applied patch (FELIX-441) from Guillaume Nodet to properly fire a framework
error event only when a bundle cannot be resolved.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@606003 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 689c1a4..3db400e 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -1451,18 +1451,28 @@
**/
protected Class loadBundleClass(FelixBundle bundle, String name) throws ClassNotFoundException
{
+ if (bundle.getInfo().getState() == Bundle.UNINSTALLED)
+ {
+ throw new IllegalStateException("Bundle is uninstalled");
+ }
+ else if (bundle.getInfo().getState() == Bundle.INSTALLED)
+ {
+ try
+ {
+ _resolveBundle(bundle);
+ }
+ catch (BundleException ex)
+ {
+ // The spec says we must fire a framework error.
+ fireFrameworkEvent(FrameworkEvent.ERROR, bundle, ex);
+ // Then throw a class not found exception.
+ throw new ClassNotFoundException(name);
+ }
+ }
Class clazz = bundle.getInfo().getCurrentModule().getClass(name);
if (clazz == null)
{
- // Throw exception.
- ClassNotFoundException ex = new ClassNotFoundException(name);
-
- // The spec says we must fire a framework error.
- fireFrameworkEvent(
- FrameworkEvent.ERROR, bundle,
- new BundleException(ex.getMessage()));
-
- throw ex;
+ throw new ClassNotFoundException(name);
}
return clazz;
}