eclipse openj9、-xx:+压缩字符串和路径名中的商标符号

2nbm6dog  于 2021-06-27  发布在  Java
关注(0)|答案(0)|浏览(267)

我刚刚注意到eclipseopenj9和 -XX:+CompactStrings vm标志。我想知道这是一个错误还是仅仅是我对某事的误解。。。?
下面是发生的情况:
从接收路径后 DirectoryStream ,如果路径具有商标符号(™) 其中,符号将转换为另一个字符,即引号(“)。
只有启用压缩字符串时才会发生这种情况。
我在windows10上使用最新的eclipseopenj9(v0.23.0)。
hotspot显然在默认情况下启用了压缩字符串,并且它没有相同的问题。
下面的示例代码应该演示这个问题:

import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;

public class TrademarkSymbol {

    public static void main(String[] args) {

        // First, create the file Test™.txt somewhere

        Path path = Paths.get("C:\\test\\Test™.txt");

        // This works (the file exists):

        System.out.println(path + " exists? " + Files.exists(path, LinkOption.NOFOLLOW_LINKS));

        // However, now try to get the path via DirectoryStream:
        Path parent = path.getParent();
        try {

            DirectoryStream<Path> stream = Files.newDirectoryStream(parent);

            stream.forEach(it -> {

                // Here, the path no longer exists, because the trademark-symbol has been replaced with "-character.

                System.out.println(it + " exists? " + Files.exists(it, LinkOption.NOFOLLOW_LINKS));
            });
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题