Closed whustedt closed 7 months ago
We've seen this in the past where something hasn't been set to UTF-8. You're not on Windows, are you?
Hello,
Thank you for your prompt response. Yes, I am currently testing on Windows. I have verified that the Java file, the Checkstyle XML configuration, and the suppressions file are all encoded in UTF-8 format.
Could you please confirm if the provided Java class parses correctly in your environment?
Thank you for your assistance.
I'm afraid I couldn't reproduce the error on Mac OS (14.1.2, latest Liberica JDK 11, IDEA 2023.3, latest plugin release).
One difference on Mac OS/Linux is that the JVM builds normally default to UTF-8, i.e.
$ java -XshowSettings:properties -version 2>&1 | grep encoding
file.encoding = UTF-8
native.encoding = UTF-8
stderr.encoding = UTF-8
stdout.encoding = UTF-8
sun.io.unicode.encoding = UnicodeBig
sun.jnu.encoding = UTF-8
Which JVM are you using, and do you know what the defaults are for it? One possibility is that there's somewhere in the pipeline that the char set is using the default, which may break it.
Also, I presume using Checkstyle directly (e.g on the command line) works, just to rule out internal Checkstyle issues?
Hello,
Thank you for your suggestion. Adjusting the "Custom VM Options" in IntelliJ IDEA resolved the issue. Adding the line -Dfile.encoding=UTF8
allowed me to successfully parse the Java file with Checkstyle. Your advice to check the VM settings was key to solving this problem.
Thank you again for your help!
My pleasure - glad we got it working for you!
I'm experiencing a parsing error in Checkstyle with the message: "The source file could not be parsed by Checkstyle." This issue arises when using character literals like 'Ä'. Replacing these with string literals (e.g., "Ä") resolves the error.
Error Message:
Original Code Causing Issue:
Seeking guidance or a workaround for this issue.
Thank you.