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

Remove specialized readXxxEntry methods from ClassReader

XMLWordPrintable

    • source
    • minimal
    • Changes to preview APIs involve minimal risk.
    • Java API
    • SE

      Summary

      Remove specialized readXxxEntry methods from ClassReader.

      Problem

      ClassReader provides a generic, type-aware readEntry to read an entry of a desired type, but there are still specialized methods for reading entries of different kinds; these methods bloat up the API.

      Solution

      Remove the specialized methods; users can always call readEntry(offset, DesiredPoolEntry.class) or readEntryOrNull(offset, DesiredPoolEntry.class) instead.

      Specification

      diff --git a/src/java.base/share/classes/java/lang/classfile/ClassReader.java b/src/java.base/share/classes/java/lang/classfile/ClassReader.java
      index 7b181180c6f..ef4a36729e6 100644
      --- a/src/java.base/share/classes/java/lang/classfile/ClassReader.java
      +++ b/src/java.base/share/classes/java/lang/classfile/ClassReader.java
      @@ -130,77 +126,6 @@ public sealed interface ClassReader extends ConstantPool
            */
           <T extends PoolEntry> T readEntryOrNull(int offset, Class<T> cls);
      
      -    /**
      -     * {@return the UTF8 entry whose index is given at the specified
      -     * offset within the classfile}
      -     * @param offset the offset of the index within the classfile
      -     * @throws ConstantPoolException if the index is out of range of the
      -     *         constant pool size, or zero, or the index does not correspond to
      -     *         a UTF8 entry
      -     */
      -    Utf8Entry readUtf8Entry(int offset);
      -
      -    /**
      -     * {@return the UTF8 entry whose index is given at the specified
      -     * offset within the classfile, or null if the index at the specified
      -     * offset is zero}
      -     * @param offset the offset of the index within the classfile
      -     * @throws ConstantPoolException if the index is out of range of the
      -     *         constant pool size, or the index does not correspond to
      -     *         a UTF8 entry
      -     */
      -    Utf8Entry readUtf8EntryOrNull(int offset);
      -
      -    /**
      -     * {@return the module entry whose index is given at the specified
      -     * offset within the classfile}
      -     * @param offset the offset of the index within the classfile
      -     * @throws ConstantPoolException if the index is out of range of the
      -     *         constant pool size, or zero, or the index does not correspond to
      -     *         a module entry
      -     */
      -    ModuleEntry readModuleEntry(int offset);
      -
      -    /**
      -     * {@return the package entry whose index is given at the specified
      -     * offset within the classfile}
      -     * @param offset the offset of the index within the classfile
      -     * @throws ConstantPoolException if the index is out of range of the
      -     *         constant pool size, or zero, or the index does not correspond to
      -     *         a package entry
      -     */
      -    PackageEntry readPackageEntry(int offset);
      -
      -    /**
      -     * {@return the class entry whose index is given at the specified
      -     * offset within the classfile}
      -     * @param offset the offset of the index within the classfile
      -     * @throws ConstantPoolException if the index is out of range of the
      -     *         constant pool size, or zero, or the index does not correspond to
      -     *         a class entry
      -     */
      -    ClassEntry readClassEntry(int offset);
      -
      -    /**
      -     * {@return the name-and-type entry whose index is given at the specified
      -     * offset within the classfile}
      -     * @param offset the offset of the index within the classfile
      -     * @throws ConstantPoolException if the index is out of range of the
      -     *         constant pool size, or zero, or the index does not correspond to
      -     *         a name-and-type entry
      -     */
      -    NameAndTypeEntry readNameAndTypeEntry(int offset);
      -
      -    /**
      -     * {@return the method handle entry whose index is given at the specified
      -     * offset within the classfile}
      -     * @param offset the offset of the index within the classfile
      -     * @throws ConstantPoolException if the index is out of range of the
      -     *         constant pool size, or zero, or the index does not correspond to
      -     *         a method handle entry
      -     */
      -    MethodHandleEntry readMethodHandleEntry(int offset);
      -
           /**
            * {@return the unsigned byte at the specified offset within the classfile}
            * @param offset the offset within the classfile

            liach Chen Liang
            liach Chen Liang
            Adam Sotona
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: