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

    • Subcomponent:
    • Resolved In Build:
      b32
    • Verification:
      Not verified

      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

          Attachments

            Issue Links

              Activity

                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: