Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4074313

Class.forName( null ) throws incorrect exception.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.2.0
    • 1.1, 1.1.2, 1.1.8, 1.2.0
    • core-libs
    • 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() );
              }
              
          }
      }

            apalanissunw Anand Palaniswamy (Inactive)
            kasmithsunw Kevin Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: