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

java.io.StreamTokenizer constructor does not catch null parameter

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2beta4
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Verified

      Description



      Name: saC57035 Date: 12/14/96


      The java_io.StreamTokenizer constructor StreamTokenizer(InputStream in)
      accept and do not check null parameter. Every call to StreamTokenizer
      object which is created using null, results in throwing undocumented
      NullPointerException.
      The constructor should not allow user create object in invalid state.

      Here is the example demonstrating this bug

      _______________________Test.java ______________________________________
      import java.io.*;

      public class Test {

      public static void main( String argv[] ) {
       StreamTokenizer st = new StreamTokenizer(null);
       try {
         st.nextToken();
         System.out.println(st);
         System.out.println("No exceptions - rather strange but alright");
       } catch (IOException e) {
         System.out.println("IOException is thrown - possible result");
       } catch (Throwable e) {
         System.out.println(e+" is thrown - this is not allowed");
       }
      }

      }
      _____________________Output_________________________________________

      java.lang.NullPointerException is thrown - this is not allowed
      ____________________________________________________________________
        ======================================================================

        Attachments

          Activity

            People

            Assignee:
            zlisunw Zhenghua Li (Inactive)
            Reporter:
            savzan Stanislav Avzan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: