Status: New
Owner: ----

New issue 715 by [email protected]: Types doesn't match JDK7 behaviour where primitive arrays are used as type parameters
http://code.google.com/p/google-guice/issues/detail?id=715

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: http://code.google.com/p/guava-libraries/source/browse/guava/src/com/google/common/reflect/Types.java#471

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en.

Reply via email to