Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1132

TypeVariableResolverTest.testVariableArray() test is failing on JDK 7

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 1.1.9.Final
    • 1.1.8.Final
    • None
    • None

    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

      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.

      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.

      Attachments

        Activity

          People

            marko.luksa@gmail.com Marko Luksa (Inactive)
            marko.luksa@gmail.com Marko Luksa (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: