Eclipse OpenJ9,-XX:+CompactStrings 和路径名中的商标符号

问题描述

我刚刚注意到 Eclipse OpenJ9 和 -XX:+CompactStrings VM 标志的一个奇怪问题。我想知道这是一个错误还是仅仅是我对某些事情的误解......?

这是发生了什么:

收到来自DirectoryStream的路径后,如果路径中有商标符号(™),该符号将被转换为另一个字符,引号(“)。

只有在启用压缩字符串时才会发生这种情况。

我在 Windows 10 上使用最新的 Eclipse OpenJ9 (v0.23.0)。

HotSpot 显然认启用了 Compact Strings,它没有同样的问题。

以下示例代码可以说明问题:

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();
        }
    }
}

解决方法

刚刚跟进,在 Eclipse OpenJ9 GitHub 存储库中创建了一个问题,该问题已在代码中修复。您可以在此处关注导致修复的整个对话:

https://github.com/eclipse/openj9/issues/11650

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...