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

javac logs an erroneous warning "requires transitive directive for an automatic"

    XMLWordPrintable

Details

    Description

      ADDITIONAL SYSTEM INFORMATION :
      Java version: 11.0.3, vendor: AdoptOpenJDK
      Java home: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
      Default locale: en_US, platform encoding: UTF-8
      OS name: "mac os x", version: "10.15.3", arch: "x86_64", family: "mac"


      A DESCRIPTION OF THE PROBLEM :
      Both SLF4J and Log4j must work with tools created for versions prior to Java 9 while taking advantage of Java 9+ features. Placing module-info.class at the root of the jar causes many tools developed prior to Java 9 to fail. As such, the developers on the openjdk mailing list recommended that the module-info.class files be placed into the META-INF/versions/9 directory. Placing the module-info.java file in that directory without a module-info.class file in the root directory is specifically documented as being acceptable in https://openjdk.java.net/jeps/238#Modular-multi-release-JAR-files in the last paragraph of that section. Yet when compiling against a jar containing a module-info.class file in META-INF/versions/9 javac will log the erroneous warning "requires transitive directive for an automatic module". It should be noted that at runtime Java does indeed treat the jar as a proper named module.

      This issue was first reported by an SLF4J user at https://jira.qos.ch/browse/SLF4J-487 but it also affects Log4j 2 as the log4j-api jar is packaged as a multi-release jar with the module-info.class file in META-INF/versions/9

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      git clone https://github.com/joakime/slf4j-487
      mvn clean install

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Successful build with no compiler warnings.
      ACTUAL -
      Successful build but with compiler warning
      [WARNING] /Users/rgoers/projects/qos/slf4j-487/src/main/java/module-info.java:[4,28] requires transitive directive for an automatic module

      ---------- BEGIN SOURCE ----------
      https://github.com/joakime/slf4j-487
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Ignore the compiler warning.

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: