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

Module imports don't work inside the same module

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 23
    • 23
    • tools
    • None
    • b25

      Consider:
      ---
      $ cat module-info.java
      import module m;

      module m {
          exports test;
          uses Api;
      }
      ---

      ---
      $ cat test/Api.java
      package test;

      public class Api {
      }
      ---

      Compiling this yields:
      ---
      $ javac --enable-preview --source 23 module-info.java test/Api.java
      module-info.java:1: error: module m does not read: m
      import module m;
      ^
      module-info.java:5: error: cannot find symbol
          uses Api;
               ^
        symbol: class Api
      Note: module-info.java uses preview features of Java SE 23.
      Note: Recompile with -Xlint:preview for details.
      2 errors
      ---

      Which is wrong, as each module reads itself.

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: