JDK 16 RFR of JDK-8250213: Address use of default constructors in com.sun.source.util

Joe Darcy joe.darcy at oracle.com
Mon Jul 27 16:25:11 UTC 2020


Hi Jon,

Updated webrev to improve the docs for non-abstract classes:

     http://cr.openjdk.java.net/~darcy/8250213.1/

Patch below. For the network version of these changes, as follow-up 
work  Alan may change the public constructor of abstract classes to 
protected.

Thanks,

-Joe

--- 
old/src/jdk.compiler/share/classes/com/sun/source/util/DocTreePathScanner.java 
2020-07-27 09:20:26.556000000 -0700
+++ 
new/src/jdk.compiler/share/classes/com/sun/source/util/DocTreePathScanner.java 
2020-07-27 09:20:25.476000000 -0700
@@ -39,6 +39,11 @@
   */
  public class DocTreePathScanner<R, P> extends DocTreeScanner<R, P> {
      /**
+     * Constructs a {@code DocTreePathScanner}.
+     */
+    public DocTreePathScanner() {}
+
+    /**
       * Scans a tree from a position identified by a tree path.
       * @param path the path
       * @param p a value to be passed to visitor methods
--- 
old/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java 
2020-07-27 09:20:28.600000000 -0700
+++ 
new/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java 
2020-07-27 09:20:27.504000000 -0700
@@ -68,6 +68,10 @@
   * @since 1.8
   */
  public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> {
+    /**
+     * Constructs a {@code DocTreeScanner}.
+     */
+    public DocTreeScanner() {}

      /**
       * Scans a single node.
--- old/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java 
2020-07-27 09:20:30.312000000 -0700
+++ new/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java 
2020-07-27 09:20:29.492000000 -0700
@@ -47,6 +47,11 @@
   */
  public abstract class DocTrees extends Trees {
      /**
+     * Constructor for subclasses to call.
+     */
+    public DocTrees() {}
+
+    /**
       * Returns a DocTrees object for a given CompilationTask.
       * @param task the compilation task for which to get the Trees object
       * @return the DocTrees object
--- 
old/src/jdk.compiler/share/classes/com/sun/source/util/JavacTask.java 
2020-07-27 09:20:32.088000000 -0700
+++ 
new/src/jdk.compiler/share/classes/com/sun/source/util/JavacTask.java 
2020-07-27 09:20:31.224000000 -0700
@@ -50,6 +50,10 @@
   * @since 1.6
   */
  public abstract class JavacTask implements CompilationTask {
+    /**
+     * Constructor for subclasses to call.
+     */
+    public JavacTask() {}

      /**
       * Returns the {@code JavacTask} for a {@code ProcessingEnvironment}.
--- 
old/src/jdk.compiler/share/classes/com/sun/source/util/TreePathScanner.java 
2020-07-27 09:20:33.688000000 -0700
+++ 
new/src/jdk.compiler/share/classes/com/sun/source/util/TreePathScanner.java 
2020-07-27 09:20:32.804000000 -0700
@@ -43,6 +43,10 @@
   * @since 1.6
   */
  public class TreePathScanner<R, P> extends TreeScanner<R, P> {
+    /**
+     * Constructs a {@code TreePathScanner}.
+     */
+    public TreePathScanner() {}

      /**
       * Scans a tree from a position identified by a TreePath.
--- 
old/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java 
2020-07-27 09:20:35.172000000 -0700
+++ 
new/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java 
2020-07-27 09:20:34.448000000 -0700
@@ -75,6 +75,10 @@
   * @since 1.6
   */
  public class TreeScanner<R,P> implements TreeVisitor<R,P> {
+    /**
+     * Constructs a {@code TreeScanner}.
+     */
+    public TreeScanner() {}

      /**
       * Scans a single node.
--- old/src/jdk.compiler/share/classes/com/sun/source/util/Trees.java 
2020-07-27 09:20:36.912000000 -0700
+++ new/src/jdk.compiler/share/classes/com/sun/source/util/Trees.java 
2020-07-27 09:20:36.004000000 -0700
@@ -53,6 +53,11 @@
   */
  public abstract class Trees {
      /**
+     * Constructor for subclasses to call.
+     */
+    public Trees() {}
+
+    /**
       * Returns a Trees object for a given CompilationTask.
       * @param task the compilation task for which to get the Trees object
       * @throws IllegalArgumentException if the task does not support 
the Trees API.
--- old/src/jdk.compiler/share/classes/com/sun/tools/javac/Main.java 
2020-07-27 09:20:38.680000000 -0700
+++ new/src/jdk.compiler/share/classes/com/sun/tools/javac/Main.java 
2020-07-27 09:20:37.764000000 -0700
@@ -34,6 +34,11 @@
   * module for details on replacement APIs.
   */
  public class Main {
+    /**
+     * Do not call.
+     */
+    @Deprecated(since="16", forRemoval=true)
+    public Main(){}

      /** Main entry point for the launcher.
       *  Note: This method calls System.exit.

On 7/23/2020 10:17 AM, Joe Darcy wrote:
> Hi Jon,
>
> For the non-abstract classes, I'm happy to change the verbiage to the 
> true (if not very informative) "Creates a $FOO."
>
> Longer term, deprecating the unintended constructors for removal would 
> be fine too. (This patch is the first in a series to clean-up the JDK 
> with the intention of introducing a new lint warning for using default 
> constructors.)
>
> Thanks,
>
> -Joe
>
>


More information about the compiler-dev mailing list