I'm trying to run this code:
public class ClassLoaderTest
{
public static void main(String[] args) throws Exception
{
Object[] obj = new Object[]{};
String cname = obj.getClass().getName();
System.out.println(cname);
ClassLoaderTest.class.getClassLoader().loadClass(cname);
}
}
But it throws a ClassNotFoundException. Interestingly, if I instead use this line:
Class.forName(cname);
it works just fine.
Whats going on here?
edit:
I'm using Java 6. The println
prints this:
[Ljava.lang.Object;