-
Bug
-
Resolution: Unresolved
-
P3
-
8, 9, 10
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 bugJDK-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
Tested on macos 10.13.5, JDK 8u172 and 10.0.1
A DESCRIPTION OF THE PROBLEM :
This is a followup for bug
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