Bug 526833 - [9] revisit default set of JDK modules in ModuleDialog (modular project)
Summary: [9] revisit default set of JDK modules in ModuleDialog (modular project)
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.7.1a   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.7.3   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard: To be verified for 4.8 M6
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-03 20:17 EDT by Stephan Herrmann CLA
Modified: 2018-02-06 11:32 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2017-11-03 20:17:04 EDT
UI Part of bug 526054:

> - JDT/UI's ModuleDialog uses
>   org.eclipse.jdt.core.provisional.JavaModelAccess.defaultRootModules(Iterable<IPackageFragmentRoot>)
>   even in a modular project.

...

> It could still be interesting to use that default for a modular project, to
> test whether clients in an unnamed module would need any --add-module options.

> This could, e.g., be achieved by a button: "Use default root modules like for
> unnamed modules", which would then populate the Contents sub-lists accordingly. 
> Note, that also persisting limit-modules must be aware if current project is
> modular to compare against the appropriate default.
Comment 1 Noopur Gupta CLA 2017-11-14 03:54:56 EST
Stephan, are you still planning to look at it for 4.7.2? Or, we can update the target.
Comment 2 Stephan Herrmann CLA 2017-11-14 04:50:35 EST
I should probably split into:

- correction a la bug 526054 - for 4.7.x

- discussion if we want an additional button - later

Still, 4.7.2 would be very ambitious even just for the first part.

I'll have a quick look into this later today.
Comment 3 Stephan Herrmann CLA 2017-11-14 17:51:41 EST
This fell through the cracks due to today's mayhem on hudson.
Comment 4 Noopur Gupta CLA 2018-02-06 02:10:07 EST
Stephan, is it still in plan for 4.7.3?
Comment 5 Stephan Herrmann CLA 2018-02-06 07:15:14 EST
(In reply to Noopur Gupta from comment #4)
> Stephan, is it still in plan for 4.7.3?

Shame on me. I'm looking at it right now, if a simple, low-risk fixed is possible.
Comment 6 Eclipse Genie CLA 2018-02-06 07:59:04 EST
New Gerrit change created: https://git.eclipse.org/r/116777
Comment 7 Stephan Herrmann CLA 2018-02-06 08:14:04 EST
(In reply to Eclipse Genie from comment #6)
> New Gerrit change created: https://git.eclipse.org/r/116777

The fixed *does* appear to be straight forward:

As stated the algorithm from JEP 261 should apply only when looking at an unnamed module. Ergo, two changes are necessary in ModuleDialog:

(1) Make initialization conditional, i.e., when the current project defines (or patches) a module, put all found modules into "Explicitly Included".

(2) When preparing the result for storing in .classpath, modifiesContents() needs to answer true under a modified condition: when looking at a named module any entry in "Available" or "Implicitly Included" will always be interpreted as a modification. Comparison to the JEP 261 list is *not* relevant in this case.

So, with (1) the dialog is correctly populated, and with (2) we ensure that the correct result is stored, which can also be validated by checking that opening and closing the dialog should never change presence/absence of a limit-modules attribute.


Relevance of this fix can be checked by the following scenario:

In a modular project
- make some changes to JRE contents, e.g., exclude all javafx* modules.
- in module-info try to complete "requires java.a|" to yield java.activation.

In the current implementation, java.activation will not be proposed, which is bad for a modular project, that has not explicitly excluded that module.

Ergo: I think it's good to have in 4.7.3 - unless someone objects.
Comment 9 Noopur Gupta CLA 2018-02-06 08:59:06 EST
+1 to include it in 4.7.3.
Comment 10 Eclipse Genie CLA 2018-02-06 09:28:04 EST
New Gerrit change created: https://git.eclipse.org/r/116792
Comment 11 Stephan Herrmann CLA 2018-02-06 09:28:44 EST
(In reply to Noopur Gupta from comment #9)
> +1 to include it in 4.7.3.

Thanks, here we go:

(In reply to Eclipse Genie from comment #10)
> New Gerrit change created: https://git.eclipse.org/r/116792
Comment 12 Eclipse Genie CLA 2018-02-06 11:31:34 EST
Gerrit change https://git.eclipse.org/r/116792 was merged to [R4_7_maintenance].
Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=5074fefa0fcfa06d0e96907f8568ff2d9769bc45
Comment 13 Stephan Herrmann CLA 2018-02-06 11:32:30 EST
(In reply to Eclipse Genie from comment #12)
> Gerrit change https://git.eclipse.org/r/116792 was merged to
> [R4_7_maintenance].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/
> ?id=5074fefa0fcfa06d0e96907f8568ff2d9769bc45

Released for 4.7.3