-
Bug
-
Resolution: Fixed
-
P3
-
17, 19, 20
ADDITIONAL SYSTEM INFORMATION :
Any version of Windows, Java 12 and later. Tested amongst others with Windows 11 22H2 and:
java version "19.0.2" 2023-01-17
Java(TM) SE Runtime Environment (build 19.0.2+7-44)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
java.util.TimeZone.getSystemTimeZoneID fails with the message:
Illegal format in tzmappings file: illegal non-newline character found at line 1, offset 46
This is caused by java.util.TimeZone.getSystemTimeZoneID using the C library open function without specifying a file mode.
If another native library changes the default file mode from _O_TEXT to _O_BINARY, getSystemTimeZoneID reads the line breaks in tzmappings without translation from \r\n to \n and chokes on the \r.
Proposed fix: Specify _O_TEXT file mode when opening a file and requiring line break translation!
REGRESSION : Last worked in version 11
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Load a native library that contains _fmode=_O_BINARY;
2. Invoke java.text.DateFormat.getDateInstance()
or anything else that triggers loading of tzmappings.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No error message.
ACTUAL -
Error message "Illegal format in tzmappings file: illegal non-newline character found at line 1, offset 46" and JDK uses GMT+1 or GMT+2 instead of Berlin timezone.
---------- BEGIN SOURCE ----------
Java Code:
public class Test {
private static native void setFileMode();
public static void main(String[] args) {
System.loadLibrary("myNativeLibrary");
setFileMode();
java.text.DateFormat.getDateInstance();
}
}
C Code:
JNIEXPORT void JNICALL Java_Test_setFileMode(JNIEnv *, jclass)
{
_fmode=_O_BINARY;
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Invoke java.text.DateFormat.getDateInstance() to trigger loading of tzmappings before loading native libraray.
FREQUENCY : always
Any version of Windows, Java 12 and later. Tested amongst others with Windows 11 22H2 and:
java version "19.0.2" 2023-01-17
Java(TM) SE Runtime Environment (build 19.0.2+7-44)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
java.util.TimeZone.getSystemTimeZoneID fails with the message:
Illegal format in tzmappings file: illegal non-newline character found at line 1, offset 46
This is caused by java.util.TimeZone.getSystemTimeZoneID using the C library open function without specifying a file mode.
If another native library changes the default file mode from _O_TEXT to _O_BINARY, getSystemTimeZoneID reads the line breaks in tzmappings without translation from \r\n to \n and chokes on the \r.
Proposed fix: Specify _O_TEXT file mode when opening a file and requiring line break translation!
REGRESSION : Last worked in version 11
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Load a native library that contains _fmode=_O_BINARY;
2. Invoke java.text.DateFormat.getDateInstance()
or anything else that triggers loading of tzmappings.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No error message.
ACTUAL -
Error message "Illegal format in tzmappings file: illegal non-newline character found at line 1, offset 46" and JDK uses GMT+1 or GMT+2 instead of Berlin timezone.
---------- BEGIN SOURCE ----------
Java Code:
public class Test {
private static native void setFileMode();
public static void main(String[] args) {
System.loadLibrary("myNativeLibrary");
setFileMode();
java.text.DateFormat.getDateInstance();
}
}
C Code:
JNIEXPORT void JNICALL Java_Test_setFileMode(JNIEnv *, jclass)
{
_fmode=_O_BINARY;
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Invoke java.text.DateFormat.getDateInstance() to trigger loading of tzmappings before loading native libraray.
FREQUENCY : always
- links to
-
Commit(master) openjdk/jdk/2d6045a2
-
Review(master) openjdk/jdk/23356