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

java.io.ObjectInputStream int available() jdk1.4 b46 correct value not returned

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 1.4.0
    • Fix Version/s: 1.4.0
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      x86, sparc
    • OS:
      linux, solaris_2.6, solaris_7, windows_nt
    • Verification:
      Verified

      Description

      java.io.ObjectInputStream int available()

      jdk1.4 build46 returned value is not ok.

      jdk1.4 build44 returned value is ok.

      Test Program :
      -------------------------------------

      import java.io.*;
      import java.util.*;


      public class AvailableTest {
          
          public static void main(String[] args) throws Exception {
             
        
             try {
                 ObjectOutputStream wfile = null;
                 ObjectInputStream rfile = null;
                 FileOutputStream wstream = new FileOutputStream("AvailableTest.ser");
      FileInputStream rstream = new FileInputStream("AvailableTest.ser");
      wfile = new ObjectOutputStream(wstream);
                 rfile = new ObjectInputStream(rstream);
                 //write total 7 bytes
                 wfile.writeByte(100);
                 wfile.writeShort(1000);
                 wfile.writeInt(2000);
                 wfile.close();
                 //read available bytes
                 int primDataavailable = rfile.available();
                 System.out.println("primDataavailable = " + primDataavailable);
                 if (primDataavailable != 7) {
                    throw new Exception("available bytes 'primDataavailable != 7' is not ok in AvailableTest");
                 }
                 rfile.close();
      System.out.println ("AvailableTest Pass");
                 //delete the test file AvailableTest.ser
                 File f = new File("AvailableTest.ser");
                 if (f.exists()) {
                    f.delete();
                 }
             } catch (Exception e) {
         System.out.println ("Exception thrown in AvailableTest Fail " + e);
             e.printStackTrace();
             }
          }
          
      }

      --------------------------------------output result on jdk1.4 build46-------
       
      H:\merlinTest\bugsFiled\Available>java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b46)
      Java HotSpot(TM) Client VM (build B45, mixed mode)

      H:\merlinTest\bugsFiled\Available>java AvailableTest
      primDataavailable = 0
      Exception thrown in AvailableTest Fail java.lang.Exception: available bytes 'primDataavailable != 7' is not ok in AvailableTest
      java.lang.Exception: available bytes 'primDataavailable != 7' is not ok in AvailableTest
              at AvailableTest.main(AvailableTest.java:27)


      --------------------------------------output result on jdk1.4 build44----------
      H:\merlinTest\bugsFiled\Available>n:\beta\b44\binaries\win\bin\java -version
      java version "1.4.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b44)
      Java HotSpot(TM) Client VM (build B44, mixed mode)

      H:\merlinTest\bugsFiled\Available>n:\beta\b44\binaries\win\bin\java AvailableTest
      primDataavailable = 7
      AvailableTest Pass

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mwarressunw Michael Warres (Inactive)
              Reporter:
              spandeorcl Shantaram Pande (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: