jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kamil Nezval" <kamil.nez...@xitee.com>
Subject OCM ReflectionUtils.implementsInterface method
Date Mon, 22 Aug 2011 08:26:32 GMT
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
View raw message