You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Oliver Heger <ol...@oliver-heger.de> on 2007/08/02 21:40:49 UTC

[lang] Extension to ClassUtils

Hi,

for some tasks related to reflection and method invocation I need the 
counter part of the ClassUtils.primitiveToWrapper() method:

/**
  * Returns the corresponding primitive type if cls is a wrapper
  * class and null otherwise.
  */
Class wrapperToPrimitive(Class cls)

If this is considered a useful extension to ClassUtils, I can provide a 
patch and unit tests.

My use case is that I need to invoke a method, and I only have the name 
and an array of parameter values (not the exact parameter types). So I 
have to check based on the types of the current parameters if a method 
signature is compatible. If the signature contains primitive types, the 
current parameter values will be wrapper types; these have to be unboxed.

Does this make sense?

Oliver

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [lang] Extension to ClassUtils

Posted by Oliver Heger <ol...@oliver-heger.de>.
Henri Yandell wrote:
> Seems good to me. Unit test should confirm symmetry between the two methods too.
> 
> Of interest:
> 
> http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=291000e179b5162d5ae0d03c598e0:WuuT?bug_id=6176992
> 
> Hen

There is a new enhancement request for this feature, including a patch [1].

Thanks for the link. It's good to know that there are people out there 
with similar problems :-)

Oliver

[1] https://issues.apache.org/jira/browse/LANG-351

> 
> On 8/2/07, Oliver Heger <ol...@oliver-heger.de> wrote:
>> Hi,
>>
>> for some tasks related to reflection and method invocation I need the
>> counter part of the ClassUtils.primitiveToWrapper() method:
>>
>> /**
>>   * Returns the corresponding primitive type if cls is a wrapper
>>   * class and null otherwise.
>>   */
>> Class wrapperToPrimitive(Class cls)
>>
>> If this is considered a useful extension to ClassUtils, I can provide a
>> patch and unit tests.
>>
>> My use case is that I need to invoke a method, and I only have the name
>> and an array of parameter values (not the exact parameter types). So I
>> have to check based on the types of the current parameters if a method
>> signature is compatible. If the signature contains primitive types, the
>> current parameter values will be wrapper types; these have to be unboxed.
>>
>> Does this make sense?
>>
>> Oliver
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [lang] Extension to ClassUtils

Posted by Henri Yandell <fl...@gmail.com>.
Seems good to me. Unit test should confirm symmetry between the two methods too.

Of interest:

http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=291000e179b5162d5ae0d03c598e0:WuuT?bug_id=6176992

Hen

On 8/2/07, Oliver Heger <ol...@oliver-heger.de> wrote:
> Hi,
>
> for some tasks related to reflection and method invocation I need the
> counter part of the ClassUtils.primitiveToWrapper() method:
>
> /**
>   * Returns the corresponding primitive type if cls is a wrapper
>   * class and null otherwise.
>   */
> Class wrapperToPrimitive(Class cls)
>
> If this is considered a useful extension to ClassUtils, I can provide a
> patch and unit tests.
>
> My use case is that I need to invoke a method, and I only have the name
> and an array of parameter values (not the exact parameter types). So I
> have to check based on the types of the current parameters if a method
> signature is compatible. If the signature contains primitive types, the
> current parameter values will be wrapper types; these have to be unboxed.
>
> Does this make sense?
>
> Oliver
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org