Mappers.instantiate issue

Georgiy Rakov georgiy.rakov at
Mon Oct 29 08:08:41 PDT 2012


there is an issue in java.util.functions.Mappers.instantiate declaration 
if I'm not mistaken. The current declaration is:

    public static <T, U> Mapper<T, U> instantiate(Class<? extends T>
    clazzT, Class<? extends U> clazzU)

Though I could suppose it should be:

    public static <T, U> Mapper<T, U> instantiate(Class<? /_*super*_/ T>
    clazzT, Class<? extends U> clazzU)

The point is following type safe code causes IllegalArgumentException 
while executing Tsub2_Type()).

    import java.util.functions.Mapper;
    import java.util.functions.Mappers;

    public class InstantiateTest {
         static class T_Type {

         public static class U_Type {
             public U_Type(Tsub_Type t) {
             public U_Type(T_Type t) {

         public static class Tsub_Type extends T_Type{

         public static class Tsub2_Type extends T_Type {

         public static void main(String []arg) {
             Mapper<T_Type, U_Type> m =
    U_Type>instantiate(Tsub_Type.class, U_Type.class);


If declaration is modified as specified above the code simply won't be 
Please give your comments.

Thanks, Georgiy.
PS: the code is attached for your convenience.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...

More information about the lambda-dev mailing list