jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Parvulescu <alex.parvule...@gmail.com>
Subject Re: OCM ReflectionUtils.implementsInterface method
Date Mon, 22 Aug 2011 09:35:12 GMT
Hi guys,

Will, why don't you create an issue & patch?

OCM hasn't had a lot of interest, it would be cool to see people looking to
get involved.

best,
alex


On Mon, Aug 22, 2011 at 10:38 AM, Will Scheidegger
<willscheidegger@mac.com>wrote:

> Hi Kamil
>
> I can confirm that this bug. I had to modify this  too. My
> implementsInterface() method looks like this now:
>
>        public static boolean implementsInterface( Class clazz, Class
> interfaceClass ) {
>
>                // Try to find the interface class in the interfaces list
>                if (clazz.getInterfaces() != null  )
>                {
>                   for ( Class foundInterface : clazz.getInterfaces() ) {
>                            if ( foundInterface == interfaceClass ||
> implementsInterface(foundInterface, interfaceClass)) {
>                                  return true;
>                           }
>                   }
>                }
>                 // Try to find from the ancestors
>                if (clazz.getSuperclass() != null)
>                {
>                    return implementsInterface(clazz.getSuperclass(),
> interfaceClass);
>                }
>
>                return false;
>        }
>
>
> Cheers,
> -will
>
>
> On 22.08.2011, at 10:26, Kamil Nezval wrote:
>
> > Hi,
> >
> > I'm using the Jackrabbit OCM library (the current version from the trunk
> folder in svn) and I've probably found a bug in
> > org.apache.jackrabbit.ocm.reflection.ReflectionUtils.
> > Current version:
> >
> >       public static boolean implementsInterface( Class clazz, Class
> > interfaceClass ) {
> >
> >               // Try to find the interface class in the interfaces list
> >               if (clazz.getInterfaces() != null  )
> >               {
> >                  for ( Class foundInterface : clazz.getInterfaces() ) {
> >                          if ( foundInterface == interfaceClass ) {
> >                                 return true;
> >                          }
> >                          return implementsInterface(foundInterface,
> > interfaceClass); // *
> >                  }
> >               }
> >               // Try to find from the ancestors
> >               if (clazz.getSuperclass() != null)
> >               {
> >                   return implementsInterface(clazz.getSuperclass(),
> > interfaceClass);
> >               }
> >
> >               return false;
> >       }
> >
> > The line marked by "*" should contain something like this (or similar):
> > if (implementsInterface(foundInterface, interfaceClass)) {
> >       return true;
> > }
> >
> > The current version checks just one interface...
> >
> > The situation shows up when I try to persist a map field that has been
> initialized by java.util.Collections.EMPTY_MAP, so
> >
> ReflectionUtils.implementsInterface(java.util.Collections.EMPTY_MAP.getClass
> > (), java.util.Map.class) always returns false.
> >
> > After fixing this method, everything works fine...
> >
> > Regards
> >
> > Kamil
> >
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message