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

Lookup::defineClass spec throws `IllegalArgumentException` if ACC_MODULE flag is set in the access_flags item

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 15
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      Hide
      `Lookup::defineClass` throws `IllegalArgumentException` instead of `NoClassDefFoundError` if it is called to define a module descriptor (i.e. `ACC_MODULE` flag is set). The compatibility risk of this behavioral change is very low because `Lookup::defineClass` is used to define a class or interface and never intends to define a module descriptor.
      Show
      `Lookup::defineClass` throws `IllegalArgumentException` instead of `NoClassDefFoundError` if it is called to define a module descriptor (i.e. `ACC_MODULE` flag is set). The compatibility risk of this behavioral change is very low because `Lookup::defineClass` is used to define a class or interface and never intends to define a module descriptor.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Change Lookup::defineClass to throw IllegalArgumentException if the given bytes has ACC_MODULE flag set in the access_flags item consistent with Lookup::defineHiddenClass.

      Problem

      Lookup::defineClass does not specify what exception to throw if the given bytes has ACC_MODULE flag set in the access_flags item. The current implementation throws NoClassDefFoundError (which is the behavior specified in JVMS 5.3.5).

      This CSR proposes Lookup::defineClass to specify and throw IllegalArgumentException if the bytes has ACC_MODULE flag set in its access_flags item to be consistent with Lookup::defineHiddenClass.

      Solution

      Specify Lookup::defineClass to throw IllegalArgumentException if the given bytes has ACC_MODULE flag set in the access_flags item

      Specification

      Spec change in the Lookup::defineClass method:

      -         * @throws IllegalArgumentException the bytes are for a class in a different package
      -         * to the lookup class
      +         * @throws IllegalArgumentException if {@code bytes} is not a class or interface
      +         * ({@code ACC_MODULE} flag is set in the value of the {@code access_flags} item) or
      +         * {@bytes} denotes a class in a different package than the lookup class

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mchung Mandy Chung
              Reporter:
              lkuskov Leonid Kuskov
              Reviewed By:
              Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: