Explicitly empty sourcepath regression

Alan Bateman Alan.Bateman at oracle.com
Fri Jun 16 06:50:07 UTC 2017


On 16/06/2017 05:07, Pepper Lebeck-Jobe wrote:
> I'll start with a question, and then give an opinion.
>
> *Question*
> Why must the source files which make up a module be on the source path for
> the module to be compiled?
>
> *Opinion*
> Build tools, especially Gradle, attempt to make reproducible builds a
> reality. One thing these tools offer is fine-grained control over the set
> of java files which will be passed to javac for compilation. Historically,
> we have even explicitly set the `-sourcepath` to be empty to tell the
> compiler not to look for source files on the classpath or in the current
> working directory. Combining this with an exact specification of which java
> files should be compiled supports a few important use cases:
>
>     1. You can exclude experimental sources (not yet ready to compile)
>     easily to unblock local development without fear that they will break the
>     build.
>     2. You can set up build logic to dynamically include or exclude specific
>     files without having to copy those files around to various directories
>     which are or are not on the source path, so that you can produce different
>     variations of a library from the original sources.
>
> We feel that having to isolate the files which make up a module into
> directories on the `-sourcepath` would limit the flexibility of the build
> system, and, possibly hurt reproducibility of the builds.
>
> *Reproduction*
> In case anyone on the list doesn't understand what I mean when I say that
> module source files are required to be on the source path, I've created a
> tiny GitHub repo <https://github.com/eljobe/modules/blob/master/README.md>,
> with instructions on reproducing what I'm seeing.
>
Jon or Jan might want to comment on this but there does appear to be a 
corner case in javac when none of the paths specified to -sourcepath 
exist and the source to compile includes a module-info.java.

That said, the javac command looks fishy and not clear why -cp and 
-sourcepath are specified when compiling the module. Are these just 
inherited from existing build code that hasn't been updated for modules? 
Have you looked at using -implicit:none rather than setting using empty 
paths?

-Alan


More information about the jigsaw-dev mailing list