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

A module requiring "java.base" with flags ACC_SYNTHETIC should be rejected

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 21
    • core-libs
    • None
    • behavioral
    • minimal
    • Hide
      The compatibility risk should be minimal. There are tools and libraries in the eco system that generate a module-info.class instead of compiling the module with a Java compiler. One tool that seems to be popular is "Moditect". It appears to generate the `requires java.base` with only ACC_MANDATED set. It is possible that there are other tools somewhere that generate bad class, in which case the class file will be rejected with a clear exception message.
      Show
      The compatibility risk should be minimal. There are tools and libraries in the eco system that generate a module-info.class instead of compiling the module with a Java compiler. One tool that seems to be popular is "Moditect". It appears to generate the `requires java.base` with only ACC_MANDATED set. It is possible that there are other tools somewhere that generate bad class, in which case the class file will be rejected with a clear exception message.
    • Class file construct
    • Implementation

      This is retroactive CSR, the change is already in JDK 21 builds.

      Summary

      Tighten up the parsing of module-info.class files to reject cases where the Module attribute has a requires table containing an entry for java.base with the ACC_SYNTHETIC flag set.

      Problem

      When parsing a module-info.class in a module on the module path, or reading a module-info.class with the java.lang.module.ModuleDescriptor.read API, the parsing doesn't currently reject the class file when the Module attribute has a requires entry for java.base with the ACC_SYNTHETIC flag set.

      Solution

      Align the implementation with JVMS 4.7.25 so that a requires entry for java.base with the ACC_SYNTHETIC flag set is rejected.

      Specification

      No specification changes, this is an implementation-only change

      No release note is currently planned for this change.

            alanb Alan Bateman
            pgundarlahal Prashanthram Gundarlahally
            Mandy Chung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: