Hello,

current spec [1] now contains following assertions related to grammar:

   A compilation unit (JLS 7.3) may contain a module declaration, in
   which case the filename of the compilation unit is typically
   |module-info.java|.

   CompilationUnit:
      [PackageDeclaration] {ImportDeclaration} {TypeDeclaration}
      ModuleDeclaration

These assertions allows to specify any of import, package or type declarations in any compilation unit, for instance module-info.java is allowed to contain any of the mentioned declarations. However currently javac in the latest jigsaw build [2] reports an error on such cases provided they are compiled in module mode. For example if we have following directory structure:

   mod\module-info.java:
   module mod {
        exports pkg;
   }

   mod\pkg\module-info.java:
   package pkg;

   class C {
   }

then compiling it by following command line with javac from [2]:

   javac -modulesourcepath . mod\module-info.java mod\pkg\module-info.java

causes following output:

   mod\pkg\module-info.java:1: error: expected 'module'
   package pkg;
   ^
   1 error

The minimized testcase is attached; in order to run it please:

1. Unzip the attached archive to some dir on Windows machined, say directory A;
2. Rename A\test\test_bat to A\test\test.bat;
3. Modify test.bat by changing JDK_HOME variable to point to your jigsaw JDK 9 installation directory;
4. Run test.bat.

It seems to me either spec or implementation issue, could you please tell if you agree.

[1] http://cr.openjdk.java.net/~mr/jigsaw/spec/lang-vm.html
[2] http://download.java.net/java/jigsaw/archive/106/binaries/jigsaw-jdk-9-ea+106_windows-x86_bin.zip

Thanks,
Georgiy.

Reply via email to