Setting Java Flight Recorder option forces English locale

Bug #1892340 reported by Roland Kaufmann
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
openjdk-lts (Ubuntu)
Fix Released
Undecided
Pushkar Kulkarni

Bug Description

(I don't have access to file bugs upstream at <https://bugs.openjdk.java.net/>)

Platform information:

$ uname -m
x86_64

$ lsb_release -d
Description: Ubuntu 20.04.1 LTS

$ dpkg -S $(readlink -f $(which java))
openjdk-11-jre-headless:amd64: /usr/lib/jvm/java-11-openjdk-amd64/bin/java

$ java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)

Test case to reproduce the problem:

$ cat > JfrOptLocBugRepro.java <<EOF
public class JfrOptLocBugRepro {
  public static void main(String[] args) {
    System.out.println(new java.text.DecimalFormat("###,###.00").format(1234567.089));
  }
}
EOF

$ javac JfrOptLocBugRepro.java

Normal behaviour; nb_NO.utf8 is a locale where the thousands grouping and decimal symbol is different from en_US.utf8 and is used as an example; I believe this problem does not only apply to this locale in particular.

$ LANG=en_US.utf8 java -cp . JfrOptLocBugRepro
1,234,567.09

$ LANG=nb_NO.utf8 java -cp . JfrOptLocBugRepro
1 234 567,09

Problem description; If a flight recorder option is added, the numeric string is no longer formatted according to the locale.

$ LANG=nb_NO.utf8 java -cp . -XX:FlightRecorderOptions= JfrOptLocBugRepro
1 234 567,09

$ LANG=nb_NO.utf8 java -cp . -XX:FlightRecorderOptions=stackdepth=256 JfrOptLocBugRepro
1,234,567.09

A cause may be that the flight recorder uses string formatting to build some internal debug strings, and this cause a premature and incorrect initialization of the locale.

Tags: reviewed
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in openjdk-lts (Ubuntu):
status: New → Confirmed
Revision history for this message
Nils-Anders Nøttseter (nils-anders) wrote :

Can confirm and reproduce using the method described by mr. Kaufmann on Ubuntu, Debian and Centos, so this should probably be pushed upstream.

Revision history for this message
Roland Kaufmann (rlndkfmn+launchpad) wrote :

This bug seems to have been fixed in newer versions; I now have:

$ dpkg -S $(readlink -f $(which java))
openjdk-17-jre-headless:amd64: /usr/lib/jvm/java-17-openjdk-amd64/bin/java

$ java -version
openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 17.0.1+12-Ubuntu-120.04, mixed mode, sharing)

and get (using the same test example as listed above):

$ LANG=nb_NO.utf8 java -cp . -XX:FlightRecorderOptions=stackdepth=256 JfrOptLocBugRepro
1 234 567,09

Revision history for this message
Vladimir Petko (vpa1977) wrote :

With 11.0.20 :

/usr/lib/jvm/java-11-openjdk-amd64/bin/java -XX:FlightRecorderOptions=stackdepth=256 -Duser.language=ru -cp . JfrOptLocBugRepro
1,234,567.09

The issue is still there

tags: added: reviewed
Revision history for this message
Pushkar Kulkarni (pushkarnk) wrote :

I've created an upstream backport request [1] for this issue.

[1] https://github.com/openjdk/jdk11u-dev/pull/2121

Revision history for this message
Pushkar Kulkarni (pushkarnk) wrote :

The upstream backport request [1] was merged.
https://github.com/openjdk/jdk11u-dev/pull/2121

Changed in openjdk-lts (Ubuntu):
assignee: nobody → Pushkar Kulkarni (pushkarnk)
Revision history for this message
Pushkar Kulkarni (pushkarnk) wrote :

This fix should hopefully be included in the JDK-11 quarterly update of Jan 2024.

Changed in openjdk-lts (Ubuntu):
status: Confirmed → In Progress
Changed in openjdk-lts (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.