Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8191137

keytool fails to format resource strings for keys for some languages after JDK-8171319

    Details

      Backports

        Description

        JDK-8171319 introduced the following code:

            private String withWeak(PublicKey key) {
                if (DISABLED_CHECK.permits(SIG_PRIMITIVE_SET, key)) {
                    return String.format(rb.getString("key.bit"),
                            KeyUtil.getKeySize(key), key.getAlgorithm());
                } else {
                    return String.format(rb.getString("key.bit.weak"),
                            KeyUtil.getKeySize(key), key.getAlgorithm());
                }
            }

        That is the format is determined by rb.getString("key.bit.weak") or rb.getString("key.bit"). For example for -Duser.language=en, these formats are:

         %d-bit %s key

        and

         %d-bit %s key (weak)

        Thus, in English this expects an integer as first argument and a String as the second. In some languages however, the formats returned by rb.getString("key.bit.weak") and rb.getString("key.bit") return different format strings: E.g. String and then Integer in French or Spanish.

        Attached is a simple reproducer. It fails with -Duser.language=es with:

        $ javac TestKeyTool
        $ java -Duser.language=es TestKeyTool
        DEBUG: Format is: Clave %s de %d bits (débil)
        Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.String
        at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4302)
        at java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2793)
        at java.util.Formatter$FormatSpecifier.print(Formatter.java:2747)
        at java.util.Formatter.format(Formatter.java:2520)
        at java.util.Formatter.format(Formatter.java:2455)
        at java.lang.String.format(String.java:2940)
        at TestKeyTool.main(TestKeyTool.java:11)

        Expected:
        Ordering of format is the same as in English: Integer then String. For example in English the reproducer prints:

        $ java -Duser.language=en TestKeyTool
        DEBUG: Format is: %d-bit %s key (weak)
        23-bit foo key (weak)
        DEBUG: Format is: %d-bit %s key
        23-bit foo key

          Issue Links

            Activity

            Hide
            weijun Weijun Wang added a comment -
            Please note that this fix does not introduce any behavior change and a real fix on the French translation will be in another bug.
            Show
            weijun Weijun Wang added a comment - Please note that this fix does not introduce any behavior change and a real fix on the French translation will be in another bug.
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk/jdk/rev/5c2f21c319c4
            User: weijun
            Date: 2017-11-14 13:47:11 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk/jdk/rev/5c2f21c319c4 User: weijun Date: 2017-11-14 13:47:11 +0000
            Hide
            sgehwolf Severin Gehwolf added a comment -
            What's the bug/subtask with the actual fix?
            Show
            sgehwolf Severin Gehwolf added a comment - What's the bug/subtask with the actual fix?
            Hide
            kkrishnamurt Kavita Krishnamurthy added a comment -
            Can we add the CR template please?
            Show
            kkrishnamurt Kavita Krishnamurthy added a comment - Can we add the CR template please?
            Hide
            andrew Andrew Hughes added a comment -
            Add associated bug for localized fix
            Show
            andrew Andrew Hughes added a comment - Add associated bug for localized fix

              People

              • Assignee:
                weijun Weijun Wang
                Reporter:
                sgehwolf Severin Gehwolf
              • Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: