ResourceParsingClassHierarchyResolver.getClassInfo(ClassDesc) throws unspecified UncheckedIOException

XMLWordPrintable

    • Type: CSR
    • Resolution: Unresolved
    • Priority: P4
    • 26
    • Component/s: core-libs
    • None
    • behavioral
    • low
    • The exceptions are no longer propagated but possibly wrapped to ensure it is an IllegalArgumentException.
    • Java API
    • SE

      Summary

      Specify that ClassHierarchyResolver implementations may fail to resolve a class or interface with exceptions.

      Problem

      Sometimes, a ClassHierarchyResolver can fail when it does not reject or skip an argument class. For example, a ZIP-scanning resolver may fail directly if it is backed by a malformed zip file, instead of returning null to indicate it does not know about a class.

      Currently, such an exception passes through the ClassFile API to the callers. This behavior is contradictory to the package specification, that ClassFile processing errors are IllegalArgumentException.

      Solution

      Add a throws clause to specify that ClassHierarchyResolver can fail in such a sporadic way.

      The behavior of the caller to CHR now wraps any non-IAE exceptions from this API to be wrapped in an IAE, as other "fatal inconsistencies" in the class file building process.

      Specification

      --- a/src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java
      +++ b/src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java
      @@ -82,6 +82,8 @@ static ClassHierarchyResolver defaultResolver() {
            * @param classDesc descriptor of the class
            * @throws IllegalArgumentException if a class shouldn't be queried for
            *         hierarchy, such as when it is inaccessible
      +     * @throws RuntimeException if the resolution runs into exceptions when
      +     *         the classDesc is supported, such as due to I/O failures
            */
           ClassHierarchyInfo getClassInfo(ClassDesc classDesc);
       
      

            Assignee:
            Chen Liang
            Reporter:
            Jaikiran Pai
            Adam Sotona
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: