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

Hide java.lang.classfile.components package to implementation

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Withdrawn
    • Icon: P3 P3
    • 24
    • core-libs
    • None
    • source
    • minimal
    • Removing a not-yet-released API has minimal compatibility risk.
    • Java API
    • SE

      Summary

      Remove java.lang.classfile.components package and its member classes as part of the Class-File API JEP.

      Problem

      java.lang.classfile.components was underused both within the JDK and early adoption users; its design defects were detected and reported very lately by users, when the ClassFile API is already known to be finalized. See the linked mailing list threads. Previous internal reviews largely focused on the core modeling classes instead of components, and it was under-reviewed as a result.

      Solution

      Remove the java.lang.classfile.components package from the public API to an internal package.

      Alternative solutions considered include continuing the preview status for this package, a new incubator module for this package, and committing the API changes immediately.

      • Continued preview or a new incubator is not possible per the JEP process; the Class-File API JEP 484 does not provide preview APIs or incubator modules, and it is too late to re-candidate and re-target the JEP to add such provisions.
      • Immediately committing the changes does not make sense, as we are yet to determine which changes we desire for the components package.

      Thus those other proposals were rejected, and hiding the package is chosen as the best way forward.

      Specification

      Removed public API java files:

      rename from src/java.base/share/classes/java/lang/classfile/components/ClassPrinter.java
      rename to src/java.base/share/classes/jdk/internal/classfile/components/ClassPrinter.java
      
      rename from src/java.base/share/classes/java/lang/classfile/components/ClassRemapper.java
      rename to src/java.base/share/classes/jdk/internal/classfile/components/ClassRemapper.java
      
      rename from src/java.base/share/classes/java/lang/classfile/components/CodeLocalsShifter.java
      rename to src/java.base/share/classes/jdk/internal/classfile/components/CodeLocalsShifter.java
      
      rename from src/java.base/share/classes/java/lang/classfile/components/CodeRelabeler.java
      rename to src/java.base/share/classes/jdk/internal/classfile/components/CodeRelabeler.java
      
      rename from src/java.base/share/classes/java/lang/classfile/components/CodeStackTracker.java
      rename to src/java.base/share/classes/jdk/internal/classfile/components/CodeStackTracker.java
      
      rename from src/java.base/share/classes/java/lang/classfile/components/package-info.java
      rename to src/java.base/share/classes/jdk/internal/classfile/components/package-info.java

      Note that ClassPrinter.java has nested classes ClassPrinter.Node, ClassPrinter.LeafNode, ClassPrinter.ListNode, ClassPrinter.MapNode.

      --- a/src/java.base/share/classes/java/lang/classfile/ClassFileTransform.java
      +++ b/src/java.base/share/classes/java/lang/classfile/ClassFileTransform.java
      @@ -60,12 +60,7 @@
        * its state must be reset for each traversal; this will happen automatically if
        * the transform is created with {@link ClassTransform#ofStateful(Supplier)} (or
        * corresponding methods for other classfile locations.)
      - * <p>
      - * Class transformation sample where code transformation is stateful:
      - * {@snippet lang="java" class="PackageSnippets" region="codeRelabeling"}
      - * <p>
      - * Complex class instrumentation sample chaining multiple transformations:
      - * {@snippet lang="java" class="PackageSnippets" region="classInstrumentation"}
      + *
        * @param <C> the transform type
        * @param <E> the element type
        * @param <B> the builder type

            liach Chen Liang
            liach Chen Liang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: