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

Compilation fails if target directory contains a `module-info.class` descriptor

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      The `javac` compiler switches into JPMS-mode if the target directory contains a compile module descriptor `module-info.class`.

      This makes the compilation result (in this case a failure) dependent not only on the CLI options and source directories, but also on the contents of the output directory.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Clone the project at:

      https://github.com/copernik-eu/bug-reproducibility/tree/main/javac-module-info-bug

      and run `make` twice.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would expect each compilation step to always work in the same way, i.e. each time:

      javac -cp lib/log4j-api.jar -d target src/example/Main.java

      is called, it will look for imported classes on the classpath.
      ACTUAL -

      The second execution of:

      javac -cp lib/log4j-api.jar -d target src/example/Main.java

      will fail while trying to resolve the modules references in the trailing `target/module-info.class` file.

      CUSTOMER SUBMITTED WORKAROUND :
      A temporary workaround consists in deleting the `module-info.class` file before each compilation step.

      FREQUENCY : always


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

              Created:
              Updated: