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

javac should fail to find a symbol, whose package exists in different visible modules

XMLWordPrintable

      The following java file can be compiled with command "javac Test.java":

      Test.java:
      package java.util;
      public class Test {
          java.util.List l = new java.util.ArrayList();
      }

      It's unreasonable. To avoid ambiguity, javac should deny any same package name in different visible modules.

      For example, if we have following 2 Test.java, which are in different modules

      Test.java:
      package my.util;
      public class Test {
          //some code
      }

      Test.java:
      package my.util;
      public class Test {
          //some code different with former Test.java
      }

      javac can compile each Test.java individually, and they can run if they can't see each other in runtime, e.g. if the different modules are not readable.

      But any module reads java.base, so the package name same as any package in java.base should be denied.

            jlahoda Jan Lahoda
            fyuan Frank Yuan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: