-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
x86
-
windows_95
Name: vi73552 Date: 03/10/99
When I try to pass null as a argument to Class.forName()
method, it works fine under JDK1.1.6 if I catch
IllegalArgumentException, but throws NullPointerException
in JDK1.2. So the code I have written runs under JDK1.1.6
while not under JDK1.2.
The source code is :
class TestStr
{
public static void main(String[] args)
{
System.out.println("Success");
try
{
Class.forName(null);
}
catch(ClassNotFoundException e)
{
System.out.println( e );
e.printStackTrace();
}
catch (IllegalArgumentException ex)
{
System.out.println( e );
}
System.out.println("Success");
}
}
Exact Text of Error Message :
Exception in Thread "main" java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:124)
at TestStr.main(TestStr.java:8).
Output of java -fullversion command :
JDK-1.2-V.
(Review ID: 55294)
======================================================================
- duplicates
-
JDK-4074313 Class.forName( null ) throws incorrect exception.
-
- Closed
-