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

Reply via email to