<Sound Dev> [PATCH] 8177951: Charset problem when the name of the sound device contains Chinese character.

CharlieJiang cqjjjzr at 126.com
Sun Jun 25 08:12:22 UTC 2017

Hello everyone.

In the last E-Mail I talked about a bug of JavaSound API. first I
apologize for the bad format(super long line).

Yesterday I said I can't compile the modified JDK because of the
compiler problem, but today I changed my compiling environment to a
VS2010 Express and I compiled the modified JDK successfully.

To my surprise, the patch works very well, at least on my machine,
I'll show you guys a picture of that: https://imgur.com/a/zcb6p

All changes in the patch is applied to
In the patch I added a function ANSIToUTF8 to convert the ANSI string
to a UTF-8 encoded Unicode string, and then I changed DS_GetDescEnum
function to let it use the convert function if the compiler is in the
Multi-Byte mode.

The patch is in this E-Mail:
There is a test to make sure the patch works correctly. It's showed in
the picture. Because your systems is in different languages, I can't
write a full-automatic unit test(a test with something like assert,
etc.).  Just as the picture, if the patch works correctly, non-ASCII
characters are displayed correctly, or them will be messy code.
Here's the code in the picture, just compile and run it without any

import javax.sound.sampled.*;
import java.util.Arrays;

import static javax.sound.sampled.AudioFormat.Encoding.PCM_SIGNED;

public class SoundEnumerator {
    public static void main(String[] args) throws LineUnavailableException {
        Mixer.Info[] mis = AudioSystem.getMixerInfo();
        for (Mixer.Info mi : mis) {
            Mixer m = AudioSystem.getMixer(mi);
            if (isMixerUsable(m)) {

    private static boolean isMixerUsable(Mixer m) throws LineUnavailableException {
        final int[] count = {0};
                .filter((it) -> it instanceof SourceDataLine.Info)
                .filter((it) -> {
                    try {
                        return m.getLine(it) instanceof SourceDataLine;
                    } catch (LineUnavailableException e) {
                        return false;
                .forEach((it) -> Arrays.stream(((DataLine.Info) it).getFormats())
                        .filter((af) -> !af.isBigEndian())
                        .filter((af) -> af.getEncoding() == PCM_SIGNED)
                        .filter((af) -> af.getSampleSizeInBits() != 24)
                        .forEach((af) -> count[0]++));
        return count[0] != 0;

Now I want to commit this little patch to the central OpenJDK
mercurial repo, any suggestion about how to do this?

Charlie Jiang

More information about the sound-dev mailing list