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

    • CSR
    • Resolution: Approved
    • P3
    • 15
    • core-libs
    • None
    • behavioral
    • low
    • 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.
    • Java API
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: