Types doesn't match JDK7 behaviour where primitive arrays are used as type parameters
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
_From [sammccall@google.com](https://code.google.com/u/111682571842123908436/) on July 17, 2012 11:37:29_
This code, using Guava's TypeToken, returns 'true' in JDK6 and 'false' in JDK7.
TypeToken listOfByteArray = new TypeToken<List<byte[]>>(){};
TypeToken listOfByteArray2 = TypeToken.of(com.google.inject.util.Types.listOf(byte[].class));
System.out.println(listOfByteArray2.isAssignableFrom(listOfByteArray));
This is because listOfByteArray2 is a ParameterizedType whose argument is a GenericArray whose component type is byte[].
This matches the JDK6 behaviour when reflecting on a field of type List<byte[]>.
In JDK7 a bug was fixed ( http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5041784); this type is now represented by a ParameterizedType whose argument is byte[].class.
So the correct behaviour, I think, is to detect the current JDK version and use the appropriate implementation.
The corresponding class in Guava does this: https://code.google.com/p/guava-libraries/source/browse/guava/src/com/google/common/reflect/Types.java#471
_Original issue: http://code.google.com/p/google-guice/issues/detail?id=715_
Contributor guide
Assessment
This issue has not been assessed yet.