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

[jnigen] Jnigen fails with FormatException again #1118

Closed
glanium opened this issue May 3, 2024 · 2 comments · Fixed by #1141
Closed

[jnigen] Jnigen fails with FormatException again #1118

glanium opened this issue May 3, 2024 · 2 comments · Fixed by #1141

Comments

@glanium
Copy link

glanium commented May 3, 2024

I've upgraded to jni 0.9.0 and jnigen 0.9.0.
However, I've got same FormatException error as #877

I've investigated the issue and there is one more cause.

https://github.com/dart-lang/native/blob/95d226d290d4d5c583c4e45b04048442f244c656/pkgs/jnigen/java/src/main/java/com/github/dart_lang/jnigen/apisummarizer/Main.java#L63C1-L71C6

When options.outputFile is specified, FileOutputStream is used for output.
This is ok.
However, when options.outputFile is not specified, System.out is used.
This is problem.
System.out is type of PrintStream!
PrintStream is encoding-aware!
So i guess jackson's JsonSerializer outputs json as UTF-16 in ja-JP locale by invoking PrintStream's encoding-aware methods.

thx.

@glanium
Copy link
Author

glanium commented May 3, 2024

In my machine,
when

java -jar .dart_tool/jnigen/ApiSummarizer.jar -c "jar\okio-3.0.0.jar;jar\okhttp-4.10.0.jar" --backend asm okhttp3.OkHttpClient > test.txt

test.txt is in UTF16-LE

when

java -jar .dart_tool/jnigen/ApiSummarizer.jar -c "jar\okio-3.0.0.jar;jar\okhttp-4.10.0.jar" --backend asm okhttp3.OkHttpClient -o test.txt

using -o option,

test.txt is in UTF8

@HosseinYousefi HosseinYousefi self-assigned this May 7, 2024
@HosseinYousefi HosseinYousefi added this to the JNI / JNIgen 0.10.0 milestone May 7, 2024
@HosseinYousefi HosseinYousefi moved this to In Progress in JNIgen tracker May 7, 2024
@HosseinYousefi
Copy link
Member

HosseinYousefi commented May 7, 2024

I see, it worked on my machine using ja-JP, that's why I closed it.

I can replace System.out with new PrintStream(System.out, true, StandardCharsets.UTF_8);and try again. I'll tag you in the PR to check it on your machine using git dependency so we're sure this time the issue is actually fixed.

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