Bug 514815 - [9] Implement --module option in command line compiler
Summary: [9] Implement --module option in command line compiler
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact: Jay Arthanareeswaran CLA
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks: 487421
  Show dependency tree
 
Reported: 2017-04-06 02:27 EDT by Jay Arthanareeswaran CLA
Modified: 2022-12-12 03:46 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jay Arthanareeswaran CLA 2017-04-06 02:27:55 EDT
The Javac help has this to say about this command line option:

  --module <module-name>, -m <module-name>
        Compile only the specified module, check timestamps

While there's not much documentation available, running the tool I gather that this is applicable only when --module-source-path option is supplied.

But it is not clear what happens when something like the following command is used:

javac -d bin --module-source-path src -m mod.one $(find src -name "*.java")

The src contains multiple modules and the above command compiles all the modules. Even a command like below ends up compiling both the modules completely:

javac -d bin --module-source-path src -m mod.one src/mod.two/q/Y.java

Only case where it appears to be working as expected (my understanding) is when no Java file is supplied via the command line.
Comment 1 Jay Arthanareeswaran CLA 2017-04-06 02:34:38 EDT
(In reply to Jay Arthanareeswaran from comment #0)
> Only case where it appears to be working as expected (my understanding) is
> when no Java file is supplied via the command line.

Such as this:

javac -d bin --module-source-path src -m mod.one

Interestingly, this is the only case where Javac is allowing compilation without passing any source files in the command. If I remove the "-m module", then Javc complains of no source being mentioned. But this doesn't make sense. 

As of today, ECJ doesn't expect any source files to be passed via the command line in a multi module mode. We will keep it this way until we have more documentation.
Comment 2 Jay Arthanareeswaran CLA 2017-04-06 02:55:08 EDT
Another note: There was no dependency of mod.one on any of other other modules. So, there's no reason to compile the other modules for the sake of resolving dependencies.
Comment 3 Jay Arthanareeswaran CLA 2017-04-07 00:12:00 EDT
More questions: What happens when a module-info.java (1st) is supplied via command line and --module option is used pointing to another (2nd) module? Whatever documents I have doesn't say anything about this. Javac ends up compiling the whole of 2nd module and only the module-info.java of the 1st. None of the other source files from the 1st module are compiled.
Comment 4 Eclipse Genie CLA 2017-04-12 11:14:14 EDT
New Gerrit change created: https://git.eclipse.org/r/94938
Comment 5 Stephan Herrmann CLA 2017-10-07 06:21:19 EDT
JEP 261 has the following (under "Single-module mode"):

"Otherwise if the --module <module> option is present then source files will be compiled as members of <module>, which will be the root module."

Ergo, the option doesn't seem to select sources, but *associate* provided source files with the given module.
Comment 6 Eclipse Genie CLA 2022-12-12 03:46:20 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.