2

I posted a fix of a problem (explained below) but haven't been able to confirm if it solves the problem. Would someone with Java 7 try the out the following Applet and report back? It would be MUCH appreciated.

AudioMixerDemo

The problem that was reported to me was that the top row of buttons which require the load of a sound clip from a jarred resource are not working. The error points to the line where the audio file is being read and says a "mark/reset" I/O exception is being thrown.

This code works for Java 6 is not working for Java 7. The offending statement follows:

AudioInputStream ais = AudioSystem.getAudioInputStream(
    AudioMixer.class.getResourceAsStream(fileName));

The inner area returns an InputStream, and I think that is where the "markability" issue arises. The issue was reported at Oracle's bug database as a backwards compatibility problem, but given a low priority.

I have recoded the above as follows:

URL url = AudioMixer.class.getResource(fileName);
AudioInputStream ais =  AudioSystem.getAudioInputStream(url); 

There is nothing in the AudioSystem API that mentions that this method will throw "mark/reset" I/O exceptions. So, I am hopeful. But I haven't been able to confirm this!

Phil Freihofner
  • 7,645
  • 1
  • 20
  • 41
  • *"The issue was reported at Oracle's bug database as a backwards compatibility problem, but given a low priority."* What bug ID/URL? – Andrew Thompson Nov 11 '11 at 10:01
  • BTW - AFAIU the ability to support mark/reset in an URL depends on the server. Some support it, some don't. A sure fire way to guarantee a mark(able)/reset(able) input stream is to read the entire `byte[]` then pass that to the constructor of a `ByteArrayInputStream`. Oh, and I don't have Java 7 installed so cannot test your applet, sorry. (I tried J7 a while ago and when it failed with my DukeBox app. I uninstalled it in disgust - will wait for a less buggy variant.) – Andrew Thompson Nov 11 '11 at 10:08
  • How do I mark this as "solved"? – Phil Freihofner Nov 11 '11 at 21:48

1 Answers1

1

The Java 7 user who reported the problem has contacted me and given a thumbs up. So I am presuming the diagnosis and fix of the backwards compatibility problem are correct, and no longer am seeking testers (unless you are just interested in checking out the AudioMixer).

Phil Freihofner
  • 7,645
  • 1
  • 20
  • 41