You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/05/29 18:34:12 UTC

[jira] [Commented] (LANG-1190) TypeUtils.isAssignable throws NullPointerException when fromType has type variables and toType generic superclass specifies type variable

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

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

GitHub user PascalSchumacher opened a pull request:

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

    LANG-1190: TypeUtils.isAssignable throws NullPointerException when fr…

    …omType has type variables and toType generic superclass specifies type variable
    
    Not sure if this is the right/best solution, so review carefully.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/PascalSchumacher/commons-lang lang_1190

Alternatively you can review and apply these changes as the patch at:

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

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #158
    
----
commit b1ed6725807382608ed45d9803f80b129a79c5a8
Author: pascalschumacher <pa...@gmx.net>
Date:   2016-05-29T18:30:36Z

    LANG-1190: TypeUtils.isAssignable throws NullPointerException when fromType has type variables and toType generic superclass specifies type variable

----


> 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)