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

Add Constructors/Methods that take a Charset parameter to APIs in java.io, java.net, java.nio and java.util

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 10
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Hide
      There is no incompatibility in this change, only new Constructors/Methods are added.

      Overloading constructors/methods may cause ambiguous reference error when the input is a literal null. There is no impact however to real world applications since all of the APIs in this specification require NPE when the parameter is null. Literal null therefore could only exist in tests for verifying the NPE requirement.
      Show
      There is no incompatibility in this change, only new Constructors/Methods are added. Overloading constructors/methods may cause ambiguous reference error when the input is a literal null. There is no impact however to real world applications since all of the APIs in this specification require NPE when the parameter is null. Literal null therefore could only exist in tests for verifying the NPE requirement.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Add overloading Constructors/Methods that take a Charset object as a parameter to APIs in java.io, java.net, java.nio and java.util. These APIs contain existing Constructors/Methods that take a Charset or Encoding name as a parameter.

      Problem

      There are a variety of APIs in the java.base module that take a charset or encoding name as a parameter and are declared to throw UnsupportedEncodingException, which is checked. Having to enter a literal charset or encoding name is inconvenient and error prone, while the check Exception is unnecessary in most cases.

      Solution

      Add overloading Constructors/Methods that take a Charset object as a parameter.

      Specification

      Add overloading Constructors/Methods to the following classes:

      java.io
      java/io/ByteArrayOutputStream.java
      java/io/PrintStream.java
      java/io/PrintWriter.java
      
      java.net
      java/net/URLDecoder.java
      java/net/URLEncoder.java
      
      java.nio
      java/nio/channels/Channels.java
      
      java.util
      java/util/Formatter.java
      java/util/Properties.java
      java/util/Scanner.java

      specdiffs attached. Below is a convenient link:

      http://cr.openjdk.java.net/~joehw/jdk10/8190577/specdiff/overview-summary.html

        Attachments

        1. specdiff_8190577_v2.zip
          218 kB
        2. specdiff_8190577_v3.zip
          219 kB
        3. specdiff_8190577_v4.zip
          219 kB
        4. specdiff_8190577.zip
          187 kB

          Issue Links

            Activity

              People

              • Assignee:
                joehw Joe Wang
                Reporter:
                smarks Stuart Marks
                Reviewed By:
                Alan Bateman, Roger Riggs
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: