jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Scheidegger <willscheideg...@mac.com>
Subject Re: OCM ReflectionUtils.implementsInterface method
Date Mon, 22 Aug 2011 10:51:12 GMT
I know, I know I should have... and wanted to... but was in a hurry and forgot :-(

Here we go (incl. patch):
https://issues.apache.org/jira/browse/OCM-45

-will

P.S.: Too bad OCM does not get a lot of interest. It's great. I get much better control than
with those standard bean utils.


On 22.08.2011, at 11:35, Alex Parvulescu wrote:

> 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
View raw message