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

Type-checked ConstantPool.entryByIndex and ClassReader.readEntryOrNull

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 23
    • None
    • core-libs
    • None

      ConstantPool.entryByIndex and ClassReader.readEntryOrNull are frequently used with their results casted, meaning that only a specific type of entry is expected; these code will throw ClassCastException instead of IllegalArgumentException as mandated by ClassFile API. We should add type-specific versions of these API like ClassReader.readEntry, so that they can throw the right type of exceptions and users can avoid ugly casts.

      In addition, ClassReader.utf8EntryByIndex can be replaced by this type-checked entryByIndex in ConstantPool.

      The API addition patch will migrate existing code that's benefitted by the new APIs.

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

              Created:
              Updated:
              Resolved: