[ 
https://issues.jboss.org/browse/WELD-1132?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marko Lukša updated WELD-1132:
------------------------------

    Git Pull Request: https://github.com/weld/core/pull/197  (was: 
https://github.com/weld/core/pull/197)
         Description: 
The problem is with how java reflection handles arrays. Different JDKs and 
supposedly even different methods in the same JDK use two different 
representations of an array:

From http://weblogs.java.net/blog/kohsuke/archive/2008/12/introspecting_g.html
{quote}
Note that there's a little overlap between Class and GenericArrayType. a type 
like String[] can be represented either as String[].class or 
GenericArrayType(String.class). Different JDK methods return different forms (I 
filed a bug on this but forgot which one), so your code should anticipate both 
patterns.
{quote}

In JDK6 {{new TypeLiteral<Integer[]>() {}.getType()}} returns 
{{GenericArrayType(Integer.class)}}, while in JDK7 it returns 
{{Integer[].class}}. 

Since {{Integer[]}} is not a generic array, we can skip using {{TypeLiteral}} 
and simply use {{Integer[].class}} as the expected value. However, 
{{TypeVariableResolver}} should also be modified so it never returns 
{{GenericArrayType}}, when the array isn't generic.


  was:
The problem is with how java reflection handles arrays. Different JDKs and 
supposedly even different methods in the same JDK use two different 
representations of an array:

From http://weblogs.java.net/blog/kohsuke/archive/2008/12/introspecting_g.html:
{quote}
Note that there's a little overlap between Class and GenericArrayType. a type 
like String[] can be represented either as String[].class or 
GenericArrayType(String.class). Different JDK methods return different forms (I 
filed a bug on this but forgot which one), so your code should anticipate both 
patterns.
{quote}

In JDK6 {{new TypeLiteral<Integer[]>() {}.getType()}} returns 
{{GenericArrayType(Integer.class)}}, while in JDK7 it returns 
{{Integer[].class}}. 

Since {{Integer[]}} is not a generic array, we can skip using {{TypeLiteral}} 
and simply use {{Integer[].class}} as the expected value. However, 
{{TypeVariableResolver}} should also be modified so it never returns 
{{GenericArrayType}}, when the array isn't generic.



    
> TypeVariableResolverTest.testVariableArray() test is failing on JDK 7
> ---------------------------------------------------------------------
>
>                 Key: WELD-1132
>                 URL: https://issues.jboss.org/browse/WELD-1132
>             Project: Weld
>          Issue Type: Bug
>    Affects Versions: 1.1.8.Final
>            Reporter: Marko Lukša
>            Assignee: Marko Lukša
>
> The problem is with how java reflection handles arrays. Different JDKs and 
> supposedly even different methods in the same JDK use two different 
> representations of an array:
> From http://weblogs.java.net/blog/kohsuke/archive/2008/12/introspecting_g.html
> {quote}
> Note that there's a little overlap between Class and GenericArrayType. a type 
> like String[] can be represented either as String[].class or 
> GenericArrayType(String.class). Different JDK methods return different forms 
> (I filed a bug on this but forgot which one), so your code should anticipate 
> both patterns.
> {quote}
> In JDK6 {{new TypeLiteral<Integer[]>() {}.getType()}} returns 
> {{GenericArrayType(Integer.class)}}, while in JDK7 it returns 
> {{Integer[].class}}. 
> Since {{Integer[]}} is not a generic array, we can skip using {{TypeLiteral}} 
> and simply use {{Integer[].class}} as the expected value. However, 
> {{TypeVariableResolver}} should also be modified so it never returns 
> {{GenericArrayType}}, when the array isn't generic.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

_______________________________________________
weld-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/weld-issues

Reply via email to