geronimo-xbean-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: svn commit: r729546 - in /geronimo/xbean/trunk/xbean-finder/src: main/java/org/apache/xbean/finder/ClassFinder.java test/java/org/acme/foo/FamilyHalloween.java test/java/org/acme/foo/Holiday.java test/java/org/apache/xbean/finder/ClassFinderTest.java
Date Mon, 29 Dec 2008 17:52:02 GMT

On Dec 26, 2008, at 2:20 PM, jlaskowski@apache.org wrote:

> +    public List<Class> findInheritedAnnotatedClasses(Class<?  
> extends Annotation> annotation) {
> +        classesNotLoaded.clear();
> +        List<Class> classes = new ArrayList<Class>();
> +        for (ClassInfo classInfo : classInfos) {
> +            try {
> +                Class clazz = classInfo.get();
> +                do {
> +                    if (clazz.isAnnotationPresent(annotation)) {
> +                        classes.add(classInfo.get());
> +                        break;
> +                    }
> +                    clazz = clazz.getSuperclass();
> +                } while (clazz != null && clazz != Object.class);
> +            } catch (ClassNotFoundException e) {
> +                classesNotLoaded.add(classInfo.getName());
> +            } catch (NoClassDefFoundError e) {
> +                classesNotLoaded.add(classInfo.getName());
> +            }
> +        }
> +        return classes;
> +    }

Unfortunately, we can't do it this way as it will cause every class in  
the classpath to be loaded.  We need to do the search with the  
metadata we keep from scanning the byte code with asm.

-David


Mime
View raw message