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

Semantic Change in FileInputStream in 1.2

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2alpha2
    • CPU:
      sparc
    • OS:
      solaris_2.5.1
    • Verification:
      Not verified

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            mr Mark Reinhold
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: