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

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 10
    • core-libs
    • None
    • minimal
    • 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.
    • Java API
    • SE

      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

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

              Created:
              Updated:
              Resolved: