commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-1190) TypeUtils.isAssignable throws NullPointerException when fromType has type variables and toType generic superclass specifies type variable
Date Sun, 31 Jul 2016 18:03:21 GMT

    [ https://issues.apache.org/jira/browse/LANG-1190?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15401276#comment-15401276
] 

ASF GitHub Bot commented on LANG-1190:
--------------------------------------

Github user asfgit closed the pull request at:

    https://github.com/apache/commons-lang/pull/158


> TypeUtils.isAssignable throws NullPointerException when fromType has type variables and
toType generic superclass specifies type variable
> -----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LANG-1190
>                 URL: https://issues.apache.org/jira/browse/LANG-1190
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.reflect.*
>    Affects Versions: 3.4
>            Reporter: Yuhau Lin
>
> {code:java}
> import static org.apache.commons.lang3.reflect.TypeUtils.*;
> import java.lang.reflect.InvocationTargetException;
> import java.lang.reflect.Type;
> import java.util.ArrayList;
> public class Demonstration {
>     public static <U> Iterable<U> someMethod() { return null; }
>     
>     public static class WorkingClass extends ArrayList { }
>     public static class FailingClass extends ArrayList<Object> { }
>     
>     
>     public static void main(String[] args) throws NoSuchMethodException, SecurityException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException {
>         Type fromType = Demonstration.class.getDeclaredMethod("someMethod").getGenericReturnType();
>         Type workingToType = wildcardType().withLowerBounds(WorkingClass.class).build();
>         Type failingToType = wildcardType().withLowerBounds(FailingClass.class).build();
>         
>         System.out.println(fromType);
>         System.out.println(workingToType);
>         System.out.println(failingToType);
>         
>         System.out.println(isAssignable(fromType, workingToType));
>         System.out.println(isAssignable(fromType, failingToType));
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message