Where do empty compilation units belong?

Jayaprakash Artanareeswaran jay.a at outlook.in
Tue Nov 20 05:27:11 UTC 2018


I have the following folder structure in a module

my.module
         -module-info.java
         - p
             -- C.java
             -- q
                 --- D.java

where C.java contains only the package declaration and D.java is empty.

When I run javac with --module-source-path and all the individual files as arguments the compiler is happy and reports no error. This behavior is different from Eclipse compiler which reports an error about "declaring a named package because this compilation unit is associated to the named module". Is this because empty compilation units are considered to be part of unnamed modules or because the D.java and hence package q are omitted?

I have been trying to find out the relevant part of the spec or any documentation that defines this behavior, but couldn't find anything on this. Can someone please tell me what the right behavior is and point me to the relevant documentation?

This Eclipse bug has more details - https://bugs.eclipse.org/bugs/show_bug.cgi?id=540067

Regards,
Jay


More information about the jigsaw-dev mailing list