Skip to content
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

Accented characters issue when using java.nio.file.Path #8792

Open
Manokha opened this issue Apr 17, 2024 · 2 comments
Open

Accented characters issue when using java.nio.file.Path #8792

Manokha opened this issue Apr 17, 2024 · 2 comments
Assignees

Comments

@Manokha
Copy link

Manokha commented Apr 17, 2024

Describe the issue
Accented characters issue when using Path.of(...)

Steps to reproduce the issue

  1. Using this test sample (GraalVMAccentedTest.java):
import java.nio.file.Path;

public final class GraalVMAccentedTest {
    public static void main(String[] args) {
        var file = Path.of("àéïôù.txt").toFile();
        System.out.println("Could instantiate file " + file.getName());
    }
}
  1. Using eclipse-temurin java 17 (locally):
javac GraalVMAccentedTest.java
java GraalVMAccentedTest
# Outputs: "Could instantiate file àéïôù.txt"
  1. Run a GraalVM image:
docker run --name graalvm-accented-test -it "ghcr.io/graalvm/graalvm-ce:ol9-java17" /bin/bash
  1. Copy the file there (from another terminal):
docker cp GraalVMAccentedTest.java graalvm-accented-test:/app/GraalVMAccentedTest.java
  1. Compile and run (from the 3rd step terminal):
# Fails without -encoding utf8
javac -encoding utf8 GraalVMAccentedTest.java
java GraalVMAccentedTest
  1. Outputs:
Exception in thread "main" java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: ?????.txt
	at java.base/sun.nio.fs.UnixPath.encode(UnixPath.java:121)
	at java.base/sun.nio.fs.UnixPath.<init>(UnixPath.java:68)
	at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:279)
	at java.base/java.nio.file.Path.of(Path.java:147)
	at GraalVMAccentedTest.main(GraalVMAccentedTest.java:5)

Describe GraalVM and your environment:

More details
I tried with different bases (ol7, ol8), turns out ol7 works. And doesn't need the "-encoding utf-8" when compiling:

  • ghcr.io/graalvm/graalvm-ce:ol9-java17 and container-registry.oracle.com/graalvm/jdk:17-ol7 are failing
  • ghcr.io/graalvm/graalvm-ce:ol8-java17 and container-registry.oracle.com/graalvm/jdk:17-ol8 are failing
  • ghcr.io/graalvm/graalvm-ce:ol7-java17 and container-registry.oracle.com/graalvm/jdk:17-ol7 are OK!
docker run --name graalvm-accented-test -it "container-registry.oracle.com/graalvm/jdk:17-ol7" /bin/bash
# ...
bash-4.2# javac GraalVMAccentedTest.java 
bash-4.2# java GraalVMAccentedTest
Could instantiate file àéïôù.txt
@fernando-valdez
Copy link
Member

Thanks for reporting this. I will try to reproduce it on my side.

@Manokha
Copy link
Author

Manokha commented Apr 18, 2024

@fernando-valdez Thanks :) Just updated the description (more details section) after trying different images, turns out it works with ol7 based images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants