How to make Eclipse compile patched modules on JDK 9+ by passing the --patch-module javac option to my project compiler? (see pic)

Eddie Bravo :

Eclipse has to allow that, since javac from JDK allows it without requiring me to contact the CIA for clearance. If eclipse does not allow that, what other Java IDE would allow me. Worst-case scenario I'll just use emacs and terminal.

Screenshot: enter image description here

Stephan Herrmann :

Most of the relevant information has already been given in comments, I'm mostly summing it up with a little background and some links:

Firstly, Eclipse does not accept a folder named java.base within your source folder. Such layout is used by javac's multi-module mode, but in an IDE like Eclipse that mode is not needed, since we have projects for grouping the modules. In particular Eclipse requires that each project contains at most one module. Now you are free to either (a) define src/main/java/java.base as a source folder, or (b) move its content one level up (so that packages start directly in src/main/java as in the olden days).

Secondly, for setting up options like --patch-module the UI has been revamped in Eclipse 2019-06, so I suggest to upgrade Eclipse (if not already done). Then you will find a new tab in the Java Build Path configuration dialog called "Module Dependencies" where you can mark your project as patching java.base. (The method from older versions of Eclipse was: find a node "Is Modular" below the library you want to patch and edit (double click) its details. This mode is still supported for a migration period, but it is no longer recommended).

Thirdly, the Java Build Path, which is used for building/compiling (as the name suggests :) ), should also be respected for launching. To make sure that compile-time and runtime see the same set of options, both dialogs (Java Build Path and Run as ...) have a button for showing the textual form of the configured options (called JPMS options in the build path configuration).

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=328360&siteId=1