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

Localization errors in CONFLICTING_XML_ELEMENT_MAPPING and NO_XML_ELEMENT_DECL

    Details

    • Subcomponent:
    • Introduced In Version:
      8
    • CPU:
      generic
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Tested on macos 10.13.5, JDK 8u172 and 10.0.1

      A DESCRIPTION OF THE PROBLEM :
      This is a followup for bug JDK-8151873, as that has been closed as incomplete. I am not the author of JDK-8151873, but I can offer example code demonstrating the problem.

      Some more details: the message bundle com/sun/xml/internal/bind/v2/model/impl/Messages.properties contains improper quoting for the first format element for the messages CONFLICTING_XML_ELEMENT_MAPPING and NO_XML_ELEMENT_DECL in all languages but English (default) and pt_BR.

      The English (and portuguese) version correctly quote a pair of braces that should be output as part of the message like this:

      '{'{0}'}'

      all other localizations replace this with the faulty

      ''{''{0}''}''

      The outer braces are not quoted in the latter version, so {''{0}''} is interpreted as format element, resulting in a NumberFormatException when formatting ( ''{0}'' is not parseable as number ).


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the attached class

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The program should exit without any output and exit code 0
      ACTUAL -
      The following exception terminates the program:

      Exception in thread "main" java.lang.IllegalArgumentException: can't parse argument number: ''{0}''

      Exit code is 1.

      ---------- BEGIN SOURCE ----------
      import javax.xml.bind.JAXBContext;
      import javax.xml.bind.JAXBElement;
      import javax.xml.bind.JAXBException;
      import javax.xml.bind.annotation.XmlElementDecl;
      import javax.xml.bind.annotation.XmlRegistry;
      import javax.xml.namespace.QName;
      import java.util.Locale;

      public class JAXBErrorExample {

          @XmlRegistry
          public static class TheObjectFactory {
              @XmlElementDecl(name="foo")
              public JAXBElement<String> createFoo1() {
                  return new JAXBElement<>(new QName(null, "foo"), String.class, "");
              }
              @XmlElementDecl(name="foo")
              public JAXBElement<String> createFoo2() {
                  return new JAXBElement<>(new QName(null, "foo"), String.class, "");
              }
          }

          public static void main(String[] args) {
              try {
                  Locale.setDefault(Locale.GERMAN);
                  JAXBContext.newInstance(TheObjectFactory.class);

              } catch (JAXBException e) {
                  // ok, should throw
              }
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              ljiang Leo Jiang
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: