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

javax.sound SPI extensions from applet's JAR don't work with plugin

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • deploy
    • x86
    • windows_xp



      Name: gm110360 Date: 07/11/2003


      FULL PRODUCT VERSION :
      java version "1.4.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
      Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)

      FULL OS VERSION :
      Any ... (I think)

      A DESCRIPTION OF THE PROBLEM :
      I have an javax.sound SPI extension for reading/transforming MP3 files so that they can be played with the javasound api. This works fine if I put the JAR file containing the SPI extension in the classpath of the client and run the code for playing audio streams as an application. It does not work however when the JAR with the SPI extension is on an HTTP server together with an applet playing audio streams and this applet is loaded with the plugin.

      I tracked the issue to: sun.plugin.security.PluginClassLoader. The findResourcesByURLPath method seems to explicitly return an empty enumeration when looking for META-INF/services/javax.sound* resources. According to the comments in the source code because the lookup occurs for every sound file played and caused a performance bottleneck.

      I think the side-effect of this fix for the performance bottleneck is worse than the original problem! Instead of returning an empty enumeration, you could perform the actual lookup the first time findResourcesByURLPath is called for a specific javax.sound.* resource and then cache those results in the class-loader. On subsequent calls you can then return the cached result. That should fix the performance issue while allowing SPI extensions for javax.audio!

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a JAR file containing an applet class and the necessary classes and resources for a javax.sound SPI extension.
      Create an HTML file containing an applet tag to load the applet from that JAR file.
      Have the applet play an audio file using the java.sound API which requires the SPI extension also in that JAR.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The sound should be played correctly, since there is an SPI extension in the classpath for that audio format.
      You will receive:

      javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input stream
      at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)

      because the SPI extensions in JARs accessed through the PluginClassLoader are not included in the getResources enumeration of that classloader.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input stream
      at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      This is a bit difficult, since it requires a full SPI extension. If you just have a look in the code of sun.plugin.security.PluginClassLoader method findResourcesByURLPath (line 210 in the 1.4.1 source I have), it should become clear even without an actual example.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None so far.
      (Review ID: 183575)
      ======================================================================

            dgu Dennis Gu (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: