JDK-8251024 : Address reliance on default constructors in the Java Sound APIs
  • Type: CSR
  • Component: client-libs
  • Sub-Component: javax.sound
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 16
  • Submitted: 2020-08-04
  • Updated: 2020-08-13
  • Resolved: 2020-08-11
Related Reports
CSR :  
Description
Summary
-------

Add explicit constructors to some classes in Java Sound APIs which using default constructors.

Problem
-------

Default constructors are not recommended for formal API classes.

Solution
--------

Add the public constructors to the public/non-abstract classes, and protected constructors to the public/abstract classes.

Specification
-------------

    src/java.desktop/share/classes/javax/sound/midi/VoiceStatus.java	
         public int volume = 0;
    +
    +    /**
    +     * Constructs a {@code VoiceStatus}.
    +     */
    +    public VoiceStatus() {}
     }

    src/java.desktop/share/classes/javax/sound/midi/spi/MidiDeviceProvider.java
        public abstract class MidiDeviceProvider {
 
    +    /**
    +     * Constructs a {@code MidiDeviceProvider}.
    +     */
    +    protected MidiDeviceProvider() {}

    src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileReader.java
        public abstract class MidiFileReader {
 
    +    /**
    +     * Constructs a {@code MidiFileReader}.
    +     */
    +    protected MidiFileReader() {}

    src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileWriter.java	         
        public abstract class MidiFileWriter {
 
    +    /**
    +     * Constructs a {@code MidiFileWriter}.
    +     */
    +    protected MidiFileWriter() {}

    src/java.desktop/share/classes/javax/sound/midi/spi/SoundbankReader.java
        public abstract class SoundbankReader {
 
    +    /**
    +     * Constructs a {@code SoundbankReader}.
    +     */
    +    protected SoundbankReader() {}

    src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileReader.java
        public abstract class AudioFileReader {
 
    +    /**
    +     * Constructs a {@code AudioFileReader}.
    +     */
    +    protected AudioFileReader() {}

    src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileWriter.java
        public abstract class AudioFileWriter {
 
    +    /**
    +     * Constructs a {@code AudioFileWriter}.
    +     */
    +    protected AudioFileWriter() {}

    src/java.desktop/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java
        public abstract class FormatConversionProvider {
 
    +    /**
    +     * Constructs a {@code FormatConversionProvider}.
    +     */
    +    protected FormatConversionProvider() {}

    src/java.desktop/share/classes/javax/sound/sampled/spi/MixerProvider.java
        public abstract class MixerProvider {
 
    +    /**
    +     * Constructs a {@code MixerProvider}.
    +     */
    +    protected MixerProvider() {}

Link for convenience:
    http://cr.openjdk.java.net/~serb/8250858/webrev.00/


Comments
Moving to Approved for JDK 16. Same notes as made on a sibling issue: https://bugs.openjdk.java.net/browse/JDK-8251211?focusedCommentId=14361922&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14361922
11-08-2020