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

"Invalid package name:" from source launcher

XMLWordPrintable

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

      Consider the following file hierarchy and content:
      ---module-info.java
      module m {}
      ---test/Test.java
      package test;

      public class Test {
          public static void main(String... args) {
              System.err.println("Hello, world!");
          }
      }
      ---.vscode/settings.json
      {}
      ---

      This can be e.g. a result of opening the directory as a workspace in VS Code.

      A packed version of the directory is also attached.

      Then running this using the source file launcher fails:
      ---
      $ ~/tools/jdk/jdk-22/bin/java test/Test.java
      Exception in thread "main" java.lang.LayerInstantiationException: Invalid package name: /vscode for module: m
              at java.base/java.lang.ModuleLayer.defineModules(ModuleLayer.java:699)
              at jdk.compiler/com.sun.tools.javac.launcher.MemoryContext.newClassLoaderFor(MemoryContext.java:240)
              at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.execute(SourceLauncher.java:202)
              at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.run(SourceLauncher.java:153)
              at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.main(SourceLauncher.java:78)
      ---

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

              Created:
              Updated:
              Resolved: