Bug 60259 - getDateInstance() and getDateTimeInstance() hang locale without fallback
Summary: getDateInstance() and getDateTimeInstance() hang locale without fallback
Status: UNCONFIRMED
Alias: None
Product: classpath
Classification: Unclassified
Component: classpath (show other bugs)
Version: unspecified
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-18 08:51 UTC by Timo Teräs
Modified: 2019-06-14 18:54 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Timo Teräs 2014-02-18 08:51:02 UTC
[Using classpath bundled with gcc 4.8.2]

If LC_MESSAGES locale is unsupported, non-existant or does not match the expected pattern AA[_bb] where AA=language (2 bytes) and bb=region (2 bytes), the locale handler goes to infinite loop.

Simple test case:
export LC_MESSAGES=C.UTF-8

And run:
System.out.println(java.text.DateFormat.getDateInstance());

This is two related problems:
1. The code involved is in classpath/java/text/DateFormat.java: getDateInstance() and getDateTimeInstance(). The exception handler calls recursively itself and causes infinite loop as the fallback locale cannot be instantiated (for some unknown reason).

2. The code in gnu/classpath/natSystemProperties.cc interprets C.UTF-8 as user.language='C.' and no user.region (since no underscore). This triggers the bug if system locale is not in the expected format.