This content has been marked as final. Show 3 replies
The class isn't being executed when it is loaded, so where the unresolvable reference is in the code can't possibly make any difference.
So I had thought too.
But it does matter.
Some more experiments showed that Class.forName fails on code containing a var decl using an unresolvable class in a try block if that code was compiled with Java 1.4 or Java 5. It does not fail when the code is compiled with J6 or 7. Must have something to do with the bytecode definition. Have tried only with Sun/Oracle Java compilers/VMs and Eclipse's built in JDT compiler/generator.
if that code was compiled with Java 1.4 or Java 5. It does not fail when the code is compiled with J6 or 7It would not wonder me if an older version JVM could not resolve classes compiled with a newer version of JVM.