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

Address reliance on default constructors in jdk.jdi

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 16
    • core-svc
    • None
    • behavioral
    • minimal
    • One constructor is added as terminally deprecates since the class only defines static members.
    • Java API
    • JDK

      Summary

      Replace several implicit default constructors of classes in the jdk.jdi module with explicit public no-arg constructors.

      Problem

      Replying on default constructors for a formal API is not recommended.

      Solution

      Replace the default constructors with equivalent explicit constructors.

      Specification

      --- old/src/jdk.jdi/share/classes/com/sun/jdi/Bootstrap.java    2020-07-27 13:24:06.454000000 -0700
      +++ new/src/jdk.jdi/share/classes/com/sun/jdi/Bootstrap.java    2020-07-27 13:24:05.842000000 -0700
      @@ -38,6 +38,11 @@
        */
      
       public class Bootstrap extends Object {
      +    /**
      +     * Do not call.
      +     */
      +    @Deprecated(since="16", forRemoval=true)
      +    public Bootstrap() {}
      
           /**
            * Returns the virtual machine manager.
      --- old/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/Connection.java   2020-07-27 13:24:07.506000000 -0700
      +++ new/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/Connection.java   2020-07-27 13:24:06.878000000 -0700
      @@ -55,6 +55,10 @@
        * @since 1.5
        */
       public abstract class Connection {
      +    /**
      +     * Constructor for subclasses to call.
      +     */
      +    public Connection() {}
      
           /**
            * Reads a packet from the target VM.
      --- old/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java 2020-07-27 13:24:08.570000000 -0700
      +++ new/src/jdk.jdi/share/classes/com/sun/jdi/connect/spi/TransportService.java 2020-07-27 13:24:07.934000000 -0700
      @@ -79,6 +79,10 @@
        * @since 1.5
        */
       public abstract class TransportService {
      +    /**
      +     * Constructor for subclasses to call.
      +     */
      +    public TransportService() {}
      
           /**
            * Returns a name to identify the transport service.
      @@ -98,6 +102,10 @@
            * The transport service capabilities.
            */
           public static abstract class Capabilities {
      +   /**
      +    * Constructor for subclasses to call.
      +    */
      +   public Capabilities() {}
      
               /**
                * Tells whether or not this transport service can support
      @@ -229,6 +237,10 @@
            * service from listening on an address.
            */
           public static abstract class ListenKey {
      +   /**
      +    * Constructor for subclasses to call.
      +    */
      +   public ListenKey() {}
      
               /**
                * Returns a string representation of the listen key.

            darcy Joe Darcy
            darcy Joe Darcy
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: