changeset 57950:ee230ad8cfef

8230723: Remove default constructors from java.lang and java.io Reviewed-by: bpb, rriggs
author darcy
date Mon, 09 Sep 2019 10:13:42 -0700
parents 1a296c9064dc
children 734f7711f87c
files src/java.base/share/classes/java/io/InputStream.java src/java.base/share/classes/java/io/ObjectInputStream.java src/java.base/share/classes/java/io/ObjectOutputStream.java src/java.base/share/classes/java/io/OutputStream.java src/java.base/share/classes/java/lang/InheritableThreadLocal.java src/java.base/share/classes/java/lang/LiveStackFrame.java src/java.base/share/classes/java/lang/ThreadDeath.java src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java src/java.base/share/classes/java/lang/reflect/Modifier.java
diffstat 10 files changed, 54 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/io/InputStream.java	Sat Aug 24 09:31:15 2019 +0530
+++ b/src/java.base/share/classes/java/io/InputStream.java	Mon Sep 09 10:13:42 2019 -0700
@@ -56,6 +56,11 @@
     private static final int DEFAULT_BUFFER_SIZE = 8192;
 
     /**
+     * Constructor for subclasses to call.
+     */
+    public InputStream() {}
+
+    /**
      * Returns a new {@code InputStream} that reads no bytes. The returned
      * stream is initially open.  The stream is closed by calling the
      * {@code close()} method.  Subsequent calls to {@code close()} have no
--- a/src/java.base/share/classes/java/io/ObjectInputStream.java	Sat Aug 24 09:31:15 2019 +0530
+++ b/src/java.base/share/classes/java/io/ObjectInputStream.java	Mon Sep 09 10:13:42 2019 -0700
@@ -1321,6 +1321,10 @@
      * Provide access to the persistent fields read from the input stream.
      */
     public abstract static class GetField {
+        /**
+         * Constructor for subclasses to call.
+         */
+        public GetField() {}
 
         /**
          * Get the ObjectStreamClass that describes the fields in the stream.
--- a/src/java.base/share/classes/java/io/ObjectOutputStream.java	Sat Aug 24 09:31:15 2019 +0530
+++ b/src/java.base/share/classes/java/io/ObjectOutputStream.java	Mon Sep 09 10:13:42 2019 -0700
@@ -879,6 +879,10 @@
      * @since 1.2
      */
     public abstract static class PutField {
+        /**
+         * Constructor for subclasses to call.
+         */
+        public PutField() {}
 
         /**
          * Put the value of the named boolean field into the persistent field.
--- a/src/java.base/share/classes/java/io/OutputStream.java	Sat Aug 24 09:31:15 2019 +0530
+++ b/src/java.base/share/classes/java/io/OutputStream.java	Mon Sep 09 10:13:42 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,11 @@
  */
 public abstract class OutputStream implements Closeable, Flushable {
     /**
+     * Constructor for subclasses to call.
+     */
+    public OutputStream() {}
+
+    /**
      * Returns a new {@code OutputStream} which discards all bytes.  The
      * returned stream is initially open.  The stream is closed by calling
      * the {@code close()} method.  Subsequent calls to {@code close()} have
--- a/src/java.base/share/classes/java/lang/InheritableThreadLocal.java	Sat Aug 24 09:31:15 2019 +0530
+++ b/src/java.base/share/classes/java/lang/InheritableThreadLocal.java	Mon Sep 09 10:13:42 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,6 +52,11 @@
 
 public class InheritableThreadLocal<T> extends ThreadLocal<T> {
     /**
+     * Creates an inheritable thread local variable.
+     */
+    public InheritableThreadLocal() {}
+
+    /**
      * Computes the child's initial value for this inheritable thread-local
      * variable as a function of the parent's value at the time the child
      * thread is created.  This method is called from within the parent
--- a/src/java.base/share/classes/java/lang/LiveStackFrame.java	Sat Aug 24 09:31:15 2019 +0530
+++ b/src/java.base/share/classes/java/lang/LiveStackFrame.java	Mon Sep 09 10:13:42 2019 -0700
@@ -116,6 +116,11 @@
      */
     public abstract class PrimitiveSlot {
         /**
+         * Constructor.
+         */
+        PrimitiveSlot() {}
+
+        /**
          * Returns the size, in bytes, of the slot.
          */
         public abstract int size();
--- a/src/java.base/share/classes/java/lang/ThreadDeath.java	Sat Aug 24 09:31:15 2019 +0530
+++ b/src/java.base/share/classes/java/lang/ThreadDeath.java	Mon Sep 09 10:13:42 2019 -0700
@@ -49,4 +49,9 @@
 public class ThreadDeath extends Error {
     @java.io.Serial
     private static final long serialVersionUID = -4417128565033088268L;
+
+    /**
+     * Constructs a {@code ThreadDeath}.
+     */
+    public ThreadDeath() {}
 }
--- a/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java	Sat Aug 24 09:31:15 2019 +0530
+++ b/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java	Mon Sep 09 10:13:42 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -459,6 +459,11 @@
      */
     public class Factory {
         /**
+         * Constructs a factory.
+         */
+        Factory() {}
+
+        /**
          * Get a concrete subclass of the top class for a given combination of bound types.
          *
          * @param speciesData the species requiring the class, not yet linked
--- a/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java	Sat Aug 24 09:31:15 2019 +0530
+++ b/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java	Mon Sep 09 10:13:42 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,12 @@
  * @since 11
  */
 public final class ConstantBootstraps {
+    /**
+     * Do not call.
+     */
+    @Deprecated(forRemoval=true, since="14")
+    public ConstantBootstraps() {}
+
     // implements the upcall from the JVM, MethodHandleNatives.linkDynamicConstant:
     /*non-public*/
     static Object makeConstant(MethodHandle bootstrapMethod,
--- a/src/java.base/share/classes/java/lang/reflect/Modifier.java	Sat Aug 24 09:31:15 2019 +0530
+++ b/src/java.base/share/classes/java/lang/reflect/Modifier.java	Mon Sep 09 10:13:42 2019 -0700
@@ -43,6 +43,12 @@
  * @since 1.1
  */
 public class Modifier {
+    /**
+     * Do not call.
+     */
+    @Deprecated(forRemoval=true, since="14")
+    public Modifier() {}
+
 
     /**
      * Return {@code true} if the integer argument includes the