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

Semantic Change in FileInputStream in 1.2

XMLWordPrintable

    • 1.2alpha2
    • sparc
    • solaris_2.5.1
    • Not verified

      Hi,

      I recently noticed a semantic change in the FileInputStream for JDK 1.2
      for solaris and figured I would mention it. In JDK 1.1.x a read would
      seemingly read all the available bytes such that:

        length = in.available();
        byte_array = new byte[length];
        bytes_read = in.read(byte_array, 0, length);

      Would read all 'length' bytes. In JDK 1.2 on solaris the read seems to only read
      the first 2k bytes.

      I've attached a simple test program that demonstrates this. I compiled it
      on 1.1.2, and ran it with the following results:

      (on 1.1.2:)

      gerlach-76% java StreamsTest /etc/passwd
      available bytes: 532
      bytes read : 532

      gerlach-77% java StreamsTest /home/bhc/images/sack2.gif
      available bytes: 151684
      bytes read : 151684

      And on 1.2:

      gerlach-89% java StreamsTest /etc/passwd
      available bytes: 532
      bytes read : 532

      gerlach-90% java StreamsTest /home/bhc/images/sack2.gif
      available bytes: 151684
      bytes read : 2048

      ----------------------------------------
      Now if you correctly continue to read from that stream you will receive all the
      bytes but this semantic change should at least be documented.

            mr Mark Reinhold
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: