JDK-6249970 : clarification needed: binary name of array type in ClassLoader.loadClass
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 5.0u2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2005-04-04
  • Updated: 2017-09-26
  • Resolved: 2017-09-26
Related Reports
Duplicate :  
Description
The Java 1.5.0 documentation of java.lang.ClassLoader.loadClass states that the given name argument must be a binary name, as defined in The Java Language Specification, Second Edition (JLS).  The problem is that it is unclear what the binary name of an array type is (and, whether java.lang.ClassLoader.loadClass is suitable at all to obtain Class instances that represent array types).  JLS (13.1) states that "The binary name of a top-level type is its canonical name [...]" but I do not find any mention in JLS whether an array type is a top-level type.  (Also, if for example the array type java.lang.String[] were a top-level type, this would mean that its binary name where "java.lang.String[]" (JLS, 6.7), but calling java.lang.Class.loadClass with this argument gives a ClassNotFoundException.)

It appears that "[Ljava/lang/String;" worked in Java 1.4 and fails in Java 1.5, and that "[Ljava.lang.String;" works in both Java 1.4 and Java 1.5, so I use the latter in my code for now...
###@###.### 2005-04-04 11:42:40 GMT

Comments
The class spec of ClassLoader was updated by JDK-6516909 that specifies: "Class objects for array classes are not created by class loaders"
26-09-2017