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

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

    XMLWordPrintable

Details

    Description

      mod/pkg/X.java ->
      public class X {
          public static void main(String[] args) {
              System.out.println("Module mod's pkg.X.main");
          }
      }

      mod/module-info.java ->
      module mod {
      }

      javac -d mod/module-info.java mod/pkg/X.java
      java -p mod -m mod/pkg.X --> "Module mod's pkg.X.main" (Works as expected)

      Now try changing the mod's requires flag:
      java --jar <asmtools.jar> jdec mod/module-info.class > mod/module-info.jcod
      Modify from 'requires' table (jcod line:42) 0x8000 to 0x1000 (ACC_MANDATED to ACC_SYNTHETIC)
      Recompile jcod to classfile:
      java --jar <asmtools.jar> jcoder mod/module-info.jcod
      cp module-info.class mod/

      Now that module 'mod' has requires table as "java.base" and access flag as ACC_SYNTHETIC(0x1000). Below command is not expected to run successfully
      java -p mod -m mod/pkg.X

      As per jvms 4.7.25. The Module Attribute (assertion id: jvms-4.7.25-300-D-G.1-B), above illustrated example should throw error.
       

      Attachments

        Issue Links

          Activity

            People

              alanb Alan Bateman
              pgundarlahal Prashanthram Gundarlahally
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: