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

Add method ClassDesc::ofInternalName

    XMLWordPrintable

Details

    • CSR
    • Status: Closed
    • P4
    • Resolution: Approved
    • 20
    • core-libs
    • None
    • source
    • minimal
    • Adding new static factory method to a sealed interface represents no compatibility risk.
    • Java API
    • SE

    Description

      Summary

      Add a static factory method constructing ClassDesc instance from class internal name.

      Problem

      There is an easy way to create a ClassDesc from a binary name (ClassDesc::of) or a field descriptor (ClassDesc::ofDescriptor) but not from an internal name. But, the internal name is common in low-level bytecode-manipulation code.

      Solution

      Add java.lang.constant.ClassDesc::ofInternalName method.

      Specification

      New method declaration in src/java.base/share/classes/java/lang/constant/ClassDesc.java:

          /**
           * Returns a {@linkplain ClassDesc} for a class or interface type,
           * given the name of the class or interface in internal form,
           * such as {@code "java/lang/String"}.
           *
           * @apiNote
           * To create a descriptor for an array type, either use {@link #ofDescriptor(String)}
           * or {@link #arrayType()}; to create a descriptor for a primitive type, use
           * {@link #ofDescriptor(String)} or use the predefined constants in
           * {@link ConstantDescs}.
           *
           * @param name the fully qualified class name, in internal (slash-separated) form
           * @return a {@linkplain ClassDesc} describing the desired class
           * @throws NullPointerException if the argument is {@code null}
           * @throws IllegalArgumentException if the name string is not in the
           * correct format
           * @jvms 4.2.1 Binary Class and Interface Names
           * @see ClassDesc#of(String)
           * @see ClassDesc#ofDescriptor(String)
           */
          static ClassDesc ofInternalName(String name) {

      Attachments

        Issue Links

          Activity

            People

              asotona Adam Sotona
              briangoetz Brian Goetz
              Jorn Vernee
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: