-
Bug
-
Resolution: Fixed
-
P3
-
1.1, 1.1.2, 1.1.8, 1.2.0
-
1.2fcs
-
generic, x86, sparc
-
generic, solaris_2.5, windows_95
-
Verified
The specification for Class.forName( String fullName ) does not specify behavior for argument fullName when it is null. The current behavior is to throw an IllegalArgumentException. The "standard" behavior for null arguments is to throw NullPointerException unless otherwise specified. Please fix the implementation to correctly throw NullPointerException.
Steps to reproduce
Compile and execute the following code:
import java.io.PrintStream;
import javasoft.sqe.harness.Status;
import javasoft.sqe.harness.Test;
public class ClassTest implements Test {
public static void main( String argv[] ) {
ClassTest test = new ClassTest();
Status status = test.run( argv, System.err, System.out );
status.exit();
}
public Status run( String argv[], PrintStream log, PrintStream ref ) {
try {
Class x = Class.forName( null );
return Status.failed( "Nothing thrown" );
} catch( NullPointerException e ) {
return Status.passed( "OKAY" );
} catch( ThreadDeath t ) {
throw t;
} catch( Throwable t ) {
return Status.failed( "Incorrect throwable: " +
t.toString() );
}
}
}
Steps to reproduce
Compile and execute the following code:
import java.io.PrintStream;
import javasoft.sqe.harness.Status;
import javasoft.sqe.harness.Test;
public class ClassTest implements Test {
public static void main( String argv[] ) {
ClassTest test = new ClassTest();
Status status = test.run( argv, System.err, System.out );
status.exit();
}
public Status run( String argv[], PrintStream log, PrintStream ref ) {
try {
Class x = Class.forName( null );
return Status.failed( "Nothing thrown" );
} catch( NullPointerException e ) {
return Status.passed( "OKAY" );
} catch( ThreadDeath t ) {
throw t;
} catch( Throwable t ) {
return Status.failed( "Incorrect throwable: " +
t.toString() );
}
}
}
- duplicates
-
JDK-4061987 Spec for Class.forName() not clear about null argument behavior
-
- Closed
-
-
JDK-4218961 Question on Class.forName(String)
-
- Closed
-
-
JDK-4228250 Class.forName("a b") throws IllegalArgumentException instead of ClassNotFoundExc
-
- Closed
-