1

In the Java Language Specification, paragraph 7.7, it states:

A 'dependency' is the observable module enumerated by resolution (as described in the java.lang.module package specification) for a given 'requires' directive.

The documentation of java.lang.module states:

Step 1: Recursive enumeration takes a set of module names, looks up each of their module declarations, and for each module declaration, recursively enumerates:

  • the module names given by the 'requires' directives with the 'transitive' modifier, and
  • at the discretion of the host system, the module names given by the 'requires' directives without the 'transitive' modifier.

I don't understand the purpose of distinguishing between 'requires' and 'requires transitive' when it comes to resolution. Any ideas?

Hicham Moustaid
  • 773
  • 6
  • 13
  • Perhaps [this](https://stackoverflow.com/q/46502453/5133585) answer your question? – Sweeper Aug 05 '23 at 02:18
  • 1
    @Sweeper I know the difference between requires and requires transitive but I don't understand why it makes a difference during module resolution – Hicham Moustaid Aug 05 '23 at 02:26
  • How would you have written the spec for module resolution otherwise? What do you think the spec should say? – Sweeper Aug 05 '23 at 02:28
  • 1
    @Sweeper I think it should simply say: "Step 1: Recursive enumeration takes a set of module names, looks up each of their module declarations, and for each module declaration, recursively enumerates the module names given by the 'requires' directives" – Hicham Moustaid Aug 05 '23 at 02:29
  • Is this perhaps awkwardly trying to state that transitive requires get priority over non-transitive ones for resolution, though, 'the host system' is free to ignore that suggestion? – rzwitserloot Aug 05 '23 at 05:06
  • @rzwitserloot I tried to apply these rules, but I ended up with many unresolved modules...Can you provide an example that illustrates what you have understood? – Hicham Moustaid Aug 07 '23 at 11:24
  • 1
    Seems to be the same question as [this one](https://stackoverflow.com/q/68927394/2711488) but has no answer yet. I’ll will (re)read into the topic tomorrow. – Holger Aug 21 '23 at 17:18

0 Answers0