[jboss-dev] Classloading Gotcha in JDK6

Jason T. Greene jason.greene at redhat.com
Wed Jun 13 18:12:33 EDT 2007


There is an undocumented system property (besides the jvm source) in JDK
5 and 6 called "sun.lang.ClassLoader.allowArraySyntax". The default
changed from true to false in JDK6. So what this means is that in JDK6,
unless you set that property to true, if you try and load a Java array
type using a classloader (e.g. "[[B") you will get a CNFE.

The compatible solution is to either interpret array types directly (not
hard), or to use the extended form of Class.forName(), which does
understand the array syntax:

Class clazz = Class.forName(className, false, loader);


Jason T. Greene
Lead, POJO Cache
JBoss, a division of Red Hat

More information about the jboss-development mailing list