zhiqinghuang / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 0 forks source link

Different methods returning char/Character-values are mapped to the same Placeholder. #115

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
When using the on() method to get a pointer to methods of a class that return 
char (or Character) values then these pointers are mixed up.

Cause of this issue is the implementation of  
ch.lambdaj.function.argument.ArgumentsFactory.getPrimitivePlaceHolder(Class<?> 
clazz, Integer placeholderId).

For characters the line 

    return Character.forDigit(placeholderId % Character.MAX_RADIX, Character.MAX_RADIX); 

determines the placeholder for the method. placeholderId starts at 
Integer.MIN_VALUE, but Character.forDigit() expects a parameter >= 0 as first 
argument and returns the null character ('\u0000') for negative values. In 
practice, the null character is returned every time, therefore. 

A simple fix could be to change the line above to

    return Character.forDigit((placeholderId - Integer.MIN_VALUE) % Character.MAX_RADIX, Character.MAX_RADIX); 

Original issue reported on code.google.com by kobold.s...@gmail.com on 7 Oct 2013 at 12:44