JDK-8210345 : The Japanese message of FileNotFoundException garbled.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 11
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2018-09-03
  • Updated: 2019-01-15
  • Resolved: 2018-09-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12
11.0.1Fixed 12 b11Fixed
Related Reports
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows10 1703 (64bit)
OpenJDK 11(Oracle JDK builds 28)

A DESCRIPTION OF THE PROBLEM :
If the file specified when reading the file does not exist, the Japanese message of FileNotFoundException that occurs is garbled.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
When reading a file, specify a file that does not exist.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
java.io.FileNotFoundException: test.txt  (������������������������������������������������������������������������������������������������������������������������������������ ������������������������������������������������������������������������������������������)
ACTUAL -
 java.io.FileNotFoundException: test.txt  (����t����@����C��������������������A����f����B������������N����g����)

---------- BEGIN SOURCE ----------
import java.io.FileNotFoundException;
import java.io.FileReader;

public class Sample {
	public static void main(String[] args) {
		try {
			FileReader fr = new FileReader("test.txt");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
regression from JDK-8200243, in which win32/getLastErrorString was updated back to use "platform encoding", but the shared/io_util.c/throwFileNotFoundException() still has the assumption that the bytes from getLastErrorString is utf8 on win32 platform, as #ifdef WIN32 why = (*env)->NewStringUTF(env, buf); #else why = JNU_NewStringPlatform(env, buf); #endif The #ifdef need to be removed. for 12 first, with possibility to backport for 11.x
04-09-2018

This is not P1/showstopper for JDK 11 but needs to be evaluated. From what I can tell, the JDK-8200243 are correct and were verified on a Chinese version of Windows. For this bug report then it would of course be useful to get some idea what the native encoding is so we can determine if there is a bug or not.
04-09-2018

To reproduce the issue, run the test case on Windows 10 Japanese OS : JDK 10.0.1 - Pass JDk 11-ea+19 - Pass JDK 11-ea+20 - Fail JDK 11-ea+28 - Fail Output in passed versions: C:\Test>C:\Test>"C:\Program Files\Java\jdk-11\bin\java" -showversion JI9057040 java version "11-ea" 2018-09-25 Java(TM) SE Runtime Environment 18.9 (build 11-ea+19) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11-ea+19, mixed mode) java.io.FileNotFoundException: testabc.txt (������������������������������������������������������) at java.base/java.io.FileInputStream.open0(Native Method) at java.base/java.io.FileInputStream.open(FileInputStream.java:219) at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157) at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112) at java.base/java.io.FileReader.<init>(FileReader.java:60) at JI9057040.main(JI9057040.java:10) Output in failed versions : java version "11-ea" 2018-09-25 Java(TM) SE Runtime Environment 18.9 (build 11-ea+20) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11-ea+20, mixed mode) java.io.FileNotFoundException: testabc.txt (?w?????t?@?) at java.base/java.io.FileInputStream.open0(Native Method) at java.base/java.io.FileInputStream.open(FileInputStream.java:219) at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157) at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112) at java.base/java.io.FileReader.<init>(FileReader.java:60) at JI9057040.main(JI9057040.java:10)
04-09-2018