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

SPEC: AudioInputStream.available description is incomplete

    Details

    • Subcomponent:
    • Resolved In Build:
      b26
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: dkR10031 Date: 12/18/2002



      The J2SE 1.4 API doc contains the following description of
      javax.sound.sampled.AudioInputStream.available():
      "
          Returns the maximum number of bytes that can be read (or skipped over)
      from this audio input stream without blocking. This limit applies only to
      the next invocation of a read or skip method for this audio input stream;
      the limit can vary each time these methods are invoked.
      ...
      Throws:
      IOException - if an input or output error occurs"

      The specification is ambiguous since it does not specify
      AudioInputStream.available() behavior when audio
      input stream is closed: whether IOException should be thrown, or
      0 should be returned by the method. The reference implementation (JDK
      1.4.2-b10) of the method throws IOException in this case.

      This bug may affect JCK1.4a test:
        api/javax_sound/sampled/AudioInputStream/index.html#close()[close001]

      ======================================================================

      Name: dkR10031 Date: 12/19/2002


      Here is the test demonstrating the behavior of the current RI:
      ------------------------- source begin ------------------------
      import java.io.ByteArrayInputStream;
      import java.io.IOException;
      import javax.sound.sampled.AudioInputStream;
      import javax.sound.sampled.AudioFormat;

      public class MyAIS {
          public static void main(String args[]) {
              ByteArrayInputStream bais = new ByteArrayInputStream(new byte[2000]);
              AudioFormat audioFormat = new AudioFormat(22050.0f, 8, 1, true, true);
              AudioInputStream ais = new AudioInputStream(bais, audioFormat, 10);
              try {
                  ais.close();
              } catch (IOException e) {
                  System.out.println("close() - IOException is thrown:"
                                     + e.getMessage());
              }

              try {
                  int length = ais.available();
                  System.out.println("Length=" + length);
              } catch (IOException e) {
                  System.out.println("IOException is thrown: " + e.getMessage());
              }
          }
      }
      ------------------------- source end -----------------------------
      Logs:
      ------------------------ Solaris-sparc log begin -----------------
      bash-2.03$ uname -a
      SunOS novo101 5.8 Generic_108528-16 sun4u sparc SUNW,Ultra-1
      bash-2.03$ /export/ld25/java/dest/jdk1.4.2-b10/solaris-sparc/bin/java -showversion MyAIS
      java version "1.4.2-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b10)
      Java HotSpot(TM) Client VM (build 1.4.2-beta-b10, mixed mode)

      IOException is thrown: Stream closed
      ------------------------ Solaris-sparc log end -------------------


      ======================================================================
      ###@###.### 2003-10-23
      fixed

        Attachments

          Activity

            People

            • Assignee:
              kpsmith Kevin Smith (Inactive)
              Reporter:
              dimasunw Dima Dima (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: