abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antoine Toulme (JIRA)" <j...@apache.org>
Subject [jira] Commented: (ABDERA-279) Faulty classloading - unreachable code
Date Tue, 11 Jan 2011 23:10:48 GMT

    [ https://issues.apache.org/jira/browse/ABDERA-279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980417#action_12980417
] 

Antoine Toulme commented on ABDERA-279:
---------------------------------------

Christine, where should I place those tests ? Where should I start ? It doesn't like there
are tests for this class at all and the method is private static, which makes it difficult
to test.

> Faulty classloading - unreachable code
> --------------------------------------
>
>                 Key: ABDERA-279
>                 URL: https://issues.apache.org/jira/browse/ABDERA-279
>             Project: Abdera
>          Issue Type: Bug
>    Affects Versions: 1.1.1
>            Reporter: Antoine Toulme
>         Attachments: fix_classloader.patch
>
>
> The Discover class uses this method to get a class:
> {code}
>       private static <T> Class<T> getClass(ClassLoader loader, String spec)
{
>         Class<T> c = null;
>         try {
>             c = (Class<T>)loader.loadClass(spec);
>             c = (Class<T>)(c != null ? c : getClass(Discover.class.getClassLoader(),
spec));
>         } catch (ClassNotFoundException e) {
>             throw new RuntimeException(e);
>         }
>         return c;
>     }
> {code}
> However the first line inside the try statement will throw a CNF exception if the class
cannot be found. As a result, the second line is never executed.
> {code}
> c = (Class<T>)(c != null ? c : getClass(Discover.class.getClassLoader(), spec));
> {code}
> The code executes recursively, which makes things harder. I would recommend changing
the way the code is currently written to avoid recursion.

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


Mime
View raw message