It seems like variants of this little program are popular on the web:
This works under Java 5 but throws an exception under Java 6. From what I can tell, the loadClass() method in Java 6 strictly enforces a "binary string" which not what is returned by the getName() method for an array.
Can anyone comment on this? It seems to have an impact on several open-source projects. I can't tell if this is an anticipated "tightening" of Java or a bug in the current Java 6 release. I've searched the web; there are references to the problem but no one is talking about the change per se.
Looking at the 1.5 javadocs for Class.getName, it states that getName returns the binary string (which is required for ClassLoader.loadClass) only for objects that are not arrays or primitives. For primitives the issue of class loading is moot, but it would not have occurred to me that the result of getName for an array can be used to load the component type of the array.
It should be easy to extract a usable name from the representation returned by getName, though.