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

Properties :: storeToXML method does not throw ClassCastException when supplied non strings

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • P3
    • Resolution: Fixed
    • None
    • 16
    • core-libs
    • b15

    Description

      Properties::storeToXML method declares that it throws ClassCastException when Properties object contains any keys or values that are not Strings:
      https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/util/Properties.html#storeToXML(java.io.OutputStream,java.lang.String,java.lang.String)
      The behavior is not matching spec.

      Sample Code:

      private void storeToXML_01() throws IOException {
              ByteArrayOutputStream os = new ByteArrayOutputStream();
              Properties pr = new Properties();
              pr.put("one", "\u7532");
              pr.put(new Integer(8), 238923);
              pr.put(new Object(), new Double(1.1));
              pr.storeToXML(os, "Test", "UTF-8");
          }

      Not throwing ClassCastException.

      Attachments

        Issue Links

          Activity

            People

              joehw Joe Wang
              amadgundi Asha Madgundi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: