-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AudioSystem.mixerInfo returns 0 mixer (Java 1.3 Service compatibility) #61
Comments
@alesj: how can we make this jar visible to the JDK class loader? What's weird is that I was pretty sure that the JDK used the JDK class loader, so it should just be visible to itself. |
I know that in JBoss Modules if you use their So even if the module can be loaded and the classes accessed you won't be able to read any of the service entries unless you import/export them. (The docs are very vague, I think "import" means available to the module itself, "export" means available to everyone). I don't know how this affects the JDK packages though. |
I know that it isn't quite the same situation, but I found a case where someone was trying to get a Java Sound service provider set up as a JBoss module: https://community.jboss.org/thread/200423?tstart=0&_sscc=t Does any of the info there help? |
Afaik, we already handle services as they should be: Imo, this here is just a case of proper visibility? |
What do you mean by "proper visibility"? |
It depends on what the classloader where you wanna load the services "sees". Since I'm saying, if all is done right, the services should be loaded; see the test. |
Well yes, but in this case it's obvious something doesn't work, @jpragey does something very simple, that is supposed to work, using an ordinary Java class that outside of JBoss Modules works just fine. So something is wrong, right? It would be nice to figure out what exactly. |
Try adding a test to the existing ServicesTest, which would mimic what @jpragey does. |
@alesj test added |
@quintesse both cases return zero mixers ... |
Do you have any audio mixers in your system? ;) |
The test will now also check for file types, to see if that returns something on your system. For me the plain Java version of the AudioSystem returns 5 mixers and 3 file types while the Ceylon runtime versions returns 0 in both cases. As long as your system has working audio you should also get a non-zero result. |
@dmlloyd any idea here? |
If I only run ServicesTestCase::testAudioMixerServices, I get Number of mixers/filetypes using plain Java = 7/3 So it looks like previous ServicesTestCase::testLoadServices, changes things somehow ... |
But that's in your (and @tombentley 's) case. In my case there's no difference when I run it one way or the other, in both cases I always get correct result in the plain Java version and always a failure in the JBoss Modules / Ceylon runtime version. |
Note that JBoss Modules fucks up with some global JVM-scope services like for XML providers, which makes it very prone to errors when run in concurrent threads. Perhaps it does something else to other providers? |
Concurrent threads as in two threads running each an instance of JBoss Modules (even in two separate class loaders). |
OK, I did some more looking around, and found a closer case to this one that was solved. Someone was trying to use the Java Sound API in JBoss, and was not seeing any supported file formats on their machine. The solution was:
Source: https://community.jboss.org/thread/197517 There is a "modules" folder in my Ceylon project, but by default, there is no "sun" subfolder there. I could create a modules/sun/jdk/main path, add an appropriate modules.xml including com.sun.media, and copy the four named SPI files to a META-INF/services subfolder. Would that work? If so, what should I use as a starting point for the modules.xml file? If not, is this something that will have to be fixed or worked around in Ceylon? Thanks! |
Moving to 1.2, unfortunately. |
Argh dammit :( |
I did some further searching, and it looks like this JBoss Modules issue also affected WildFly, and that it was fixed in their latest release: https://issues.jboss.org/browse/WFLY-768 I hope that this helps to fix the issue. Aside from that, if anyone can help with a workaround as per my previous post, please let me know. |
That's nice! If only I had an idea how to apply it to our situation. |
The actual module.xml file they use for WildFly is this one: https://github.com/wildfly/wildfly/blob/84a3f370ce355fb1f390923055d25ad8e7a73eb3/build/src/main/resources/modules/system/layers/base/sun/jdk/main/module.xml |
I tried applying it to our runtime and even jboss modules but that doesn't help any, so I'm afraid this is something that needs to happen at a much lower level. But I really have no idea. I was hoping @alesj could have some insights. |
I tried again with Ceylon 1.2 running under Java 8, and still get 0 mixers. Is there anything that I could try or provide in order to help identify the exact cause of this issue? I would really like to help get this fixed. |
Well, with Ceylon 1.2.1 (github) I can get some mixers, by calling ceylon from Java with the Main API. That is, I have a package sound.test;
import com.redhat.ceylon.compiler.java.runtime.Main;
public class Run {
public static void main(String[] args){
Main.runModule("sound.test", "1.0.0", "sound.test.run_");
}
} and a Ceylon // sound.test.run.ceylon
import javax.sound.sampled {
Mixer,
AudioSystem
}
import java.lang {
ObjectArray
}
shared void run() {
ObjectArray<Mixer.Info> mixers = AudioSystem.mixerInfo;
print("Mixers: ``mixers.size``" );
} Module.ceylon: native("jvm")
module sound.test "1.0.0" {
import java.base "7";
import java.desktop "7";
} I run it with openJDK 1.7.0 64 bits (on Linux Mint) by:
And it prints:
I failed running it on Eclipse (Run as/Java Application); I added a bunch of jars to the classpath, but it finally failed to find [sound.test-1.0.0.car]. Maybe it's an Eclipse plugin issue? |
Thanks for looking into it! If it helps, I know that it is experimental, but after reading your post I just tried running my Ceylon code (similar to yours, but Java 8) in IntelliJ IDEA. It also finds 0 Mixers. |
Guys, FTR, this issue has moved to eclipse-archived/ceylon#4856 you should comment there now. Thanks. |
When I run the following Ceylon code :
I get 0 results; however when I run the following Java code (in the same ceylon project):
I get 5 results.
I investigated it with eclipse debugger; it ended up in
sun.misc.Service$LazyIterator.hasNext()
loading"META-INF/services/javax.sound.sampled.spi.MixerProvider"
byCeylonModuleClassLoader.getResources()
, which returned an empty enumeration.In pure java it is loaded by
sun.misc.Launcher.AppClassLoader.getResources()
returns 2 values.On my PC (linux 64 / openJDK 7)
META-INF/services/javax.sound.sampled.spi.MixerProvider
is in/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/resources.jar
.So the PB is probably a more general Java 1.3 Service SPI and Ceylon class loading compatibility issue than a strictly java audio one.
Full project:
https://drive.google.com/file/d/0B09FzhUz_CgbMkhRenpWQXdfQ2c/edit?usp=sharing
The text was updated successfully, but these errors were encountered: