You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Richard S. Hall (JIRA)" <ji...@apache.org> on 2009/02/23 16:42:01 UTC

[jira] Commented: (FELIX-953) Bundle#loadClass sometimes return null instead of throwing a CNFE

    [ https://issues.apache.org/jira/browse/FELIX-953?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12675951#action_12675951 ] 

Richard S. Hall commented on FELIX-953:
---------------------------------------

The functionality around IModule.getClass() has changed a lot lately, so not everything may be so well thought out yet, but it is unclear to me if you have uncovered a specific issue or just something you see as an inconsistency?

Regarding IWire.getClass(), this specifically works differently. An exception aborts the search, whereas a null continues the search. Terrible documentation on this, I know. I will use this issue to improve the JavaDoc on IWire.

> Bundle#loadClass sometimes return null instead of throwing a CNFE
> -----------------------------------------------------------------
>
>                 Key: FELIX-953
>                 URL: https://issues.apache.org/jira/browse/FELIX-953
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>            Reporter: Guillaume Nodet
>            Priority: Blocker
>         Attachments: FELIX-953.patch
>
>
> Here is a patch:
> {code}
> Index: src/main/java/org/apache/felix/framework/Felix.java
> ===================================================================
> --- src/main/java/org/apache/felix/framework/Felix.java (revision 746347)
> +++ src/main/java/org/apache/felix/framework/Felix.java (working copy)
> @@ -1338,7 +1338,12 @@
>                  throw new ClassNotFoundException(name, ex);
>              }
>          }
> -        return bundle.getCurrentModule().getClassByDelegation(name);
> +        Class clazz = bundle.getCurrentModule().getClassByDelegation(name);
> +        if (clazz == null)
> +        {
> +            throw new ClassNotFoundException(name);
> +        }
> +        return clazz;
>      }
>  
>      /**
> {code}
> I'm wondering if there any reason why ModuleImpl#getClassByDelegation(String) returns null instead of throwing a NPE.
> Browsing through the code, it seems there are several places where a null value is checked, then a CNFE thrown.
> This would also avoid possible NPE in felix code as in Felix#createBundleActivator.
> I think it would be nice to iron the definition of IModule#getClassByDelegation to either remove the thrown CNFE or never returns null, as currently both can happen.
> The IWire interface has exactly the same problem.
> I will try to come up with a patch which will never return a null value for both interfaces.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.