JDK-4889311 : javax.sound SPI extensions from applet's JAR don't work with plugin
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2003-07-11
  • Updated: 2005-05-24
  • Resolved: 2005-05-24
Related Reports
Duplicate :  
Description

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) 
======================================================================

Comments
EVALUATION This will be considered in Mustang. ###@###.### 2003-09-16 We will revisit this issue in the later release. ###@###.### 2004-12-09 17:19:36 GMT This issue has been addressed by the fix in #6215746. ###@###.### 2005-05-24 23:24:59 GMT
09-12-2004

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
14-06-2004