> AudioSynthesizer has a method open(line, config) which is the only way
> of configuring its parameters and thus it seems
> (https://bugs.openjdk.org/browse/JDK-6941027) that it was intended to
> be made public.

I can't spot what text in that bug is about this  ....

> It is not the case in JDK 21. There were other useful
> classes, like FFT, that are also no longer accessible.

"accessible" is not "public".
Anyone who found a need for a public API in JDK 7, or 8 should have submitted an RFE then, not hack around it and then wait until the module system made it harder to hack around to ask for it.

The thread that could not be located is this one https://mail.openjdk.org/pipermail/sound-dev/2016-November/000493.html

The RFE that exists for this is https://bugs.openjdk.org/browse/JDK-8170518

If there is still REAL interest in this we can take another look but it would be JDK 24 at this point.

-phil.


On 7/11/24 10:22 AM, SWinxy wrote:
I tried to dig into the archives for the two rotted links.

The first is a link to an email <https://mail.openjdk.org/pipermail/audio-engine-dev/2007-October/000024.html> from Florian Bomers on Oct 12, 2007. He thought the class should be public:

>> As a 1st step I suggest to create such interface in com.sun.media.sound
>> package, and them move it to javax.sound.midi.

> I don't see an advantage for going in 2 steps, I'd prefer to put
> it in javax.sound.midi directly.

I couldn't find the second link, though. It gives no hint as to where or when it was emailed. It's likely in a jdk9 mailing list, but those are extensive and the mail server doesn't have a search function.

If you /really/ need it, and you are okay with hacking your way into places where you shouldn't be, add --add-opens java.desktop/com.sun.media.sound=ALL-UNNAMED as a VM argument. Then, the following forbidden knowledge may work:

Class<?> synth = Class.forName("com.sun.media.sound.AudioSynthesizer");
Class<?> audio = Class.forName("com.sun.media.sound.SoftSynthesizer");

Method open = synth.getMethod("open", SourceDataLine.class, Map.class);
Constructor<?> declaredConstructor = audio.getDeclaredConstructor();
declaredConstructor.setAccessible(true);
Object o = declaredConstructor.newInstance();

open.setAccessible(true);
open.invoke(o, null, null);

It's horrible but it seems to work in my tests. I wouldn't advise this; reflection to access protected classes is a Bad Idea.

SWinxy

On Fri, Jul 5, 2024 at 2:50 PM Aleksei Ivanov <alexey.iva...@oracle.com> wrote:

    Hi Ithinu,

    This message belongs in client-libs-dev mailing list.

    I see Dalibor's message, “It didn't get done in time for JDK 9.”
    Yet the
    link in his message is broken now.

    Let's see if anyone has more details.

    On 2024-07-04 23:53, Ithinu wrote:
    > Hi,
    >
    > AudioSynthesizer has a method open(line, config) which is the
    only way
    > of configuring its parameters and thus it seems
    > (https://bugs.openjdk.org/browse/JDK-6941027) that it was
    intended to
    > be made public. It is not the case in JDK 21. There were other
    useful
    > classes, like FFT, that are also no longer accessible.
    >
    > According to
    >
    
https://forums.oracle.com/ords/apexds/post/com-sun-media-sound-in-java-9-0673

    > "it didn't get done in time for JDK 9".
    >
    > Is it plausible that someone will eventually look into that? Thanks.
-- Regards,
    Alexey

Reply via email to