JDK-8190577 : Add Constructors/Methods that take a Charset parameter to APIs in java.io, java.net, java.nio and java.util
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.io
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 10
  • Submitted: 2017-11-02
  • Updated: 2022-07-04
  • Resolved: 2017-12-07
Related Reports
CSR :  
Duplicate :  
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



Comments
Is there a reason ByteArrayOutputStream uses the phrase "default replacement string" and the other changes in java.io use "substitution sequence"? Moving to Approved.
07-12-2017