-
Bug
-
Resolution: Fixed
-
P1
-
1.0.2
-
1.1
-
sparc
-
solaris_2.5
-
Not verified
Name: saf@russia Date: 08/05/96
This bug was found by St.Petersburg Java SQE team (by Stanislav Avzan).
The java.lang.Class.forName method does not work with interface
names according to the Java language specification.
The Java Language specification
(Pre-Release Version 1.0, Draft 5.2 - July 3, 1996)
says the following (please see item 20.3.8):
"20.3.8 public static Class forName(String className)
throws ClassNotFoundException
Given the name of a class as a string, this method attempts to locate, load,
and link the class (12.2). If it succeeds, then a
reference to the Class object for the class is returned. If it fails, then a
ClassNotFoundException is thrown."
The bug found in Class.forName(String) is as follows:
For any String starting with '[', it returns some 'silly' reference
instead of throwing ClassNotFoundException.
Here is the minimized test:
---------fn.java-------------------------
public class fn {
public static void main( String[] argv ) {
try {
Class c = Class.forName("[ Anything You Like");
System.out.println("This output is unexpected: "+c);
} catch(ClassNotFoundException e) {
System.out.println("Everything is OK");
}
}
}
------ The output of the test : ----------
java fn
This output is unexpected: class [ Anything You Like
-----------------------------------------
Workaround:
None
======================================================================