Cyclic dependencies during multi-module compilation

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Cyclic dependencies during multi-module compilation

Nicolai Parlog
 Hi!

In early access builds, multi-module compilation would fail if there was
a dependency cycle between the involved modules. I just realized that
that is no longer the case in 9.0.1 and later (up to Java 11).

I'm interested to learn the background for that decision? I considered
that check A Good Thing - why was it removed?

 so long ... Nicolai



--

PGP Key:
    http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509

Web:
    http://codefx.org
        a blog about software development
    https://www.sitepoint.com/java
        high-quality Java/JVM content
    http://do-foss.de
        Free and Open Source Software for the City of Dortmund

Twitter:
    https://twitter.com/nipafx
Reply | Threaded
Open this post in threaded view
|

Re: Cyclic dependencies during multi-module compilation

Zheka Kozlov
Hi Nicolai.

I cannot reproduce what you said. I'm using JDK 10.0.1. I created two
modules moduleA and moduleB which require each other. When I tried to
compile, javac failed with an error: cyclic dependence involving module.

Do you observer a different behavior?

2018-05-08 15:01 GMT+07:00 Nicolai Parlog <[hidden email]>:

>  Hi!
>
> In early access builds, multi-module compilation would fail if there was
> a dependency cycle between the involved modules. I just realized that
> that is no longer the case in 9.0.1 and later (up to Java 11).
>
> I'm interested to learn the background for that decision? I considered
> that check A Good Thing - why was it removed?
>
>  so long ... Nicolai
>
>
>
> --
>
> PGP Key:
>     http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509
>
> Web:
>     http://codefx.org
>         a blog about software development
>     https://www.sitepoint.com/java
>         high-quality Java/JVM content
>     http://do-foss.de
>         Free and Open Source Software for the City of Dortmund
>
> Twitter:
>     https://twitter.com/nipafx
>
Reply | Threaded
Open this post in threaded view
|

Re: Cyclic dependencies during multi-module compilation

Alan Bateman
In reply to this post by Nicolai Parlog
On 08/05/2018 09:01, Nicolai Parlog wrote:
>   Hi!
>
> In early access builds, multi-module compilation would fail if there was
> a dependency cycle between the involved modules. I just realized that
> that is no longer the case in 9.0.1 and later (up to Java 11).
This sounds like a bug and I would expect tests to be failing if javac
doesn't detect the cycle. Can you create a small test case to
demonstrate the issue you are seeing?

-Alan
Reply | Threaded
Open this post in threaded view
|

Re: Cyclic dependencies during multi-module compilation

Nicolai Parlog
In reply to this post by Zheka Kozlov
 Hi Zheka,

this branch demonstrates what I describe:

        https://github.com/CodeFX-org/demo-jpms-monitor/tree/break-cyclic-dependency-compile-time

Run `multi-compile.sh && run.sh` and you will see the compiler happily
creating the modules whereas the runtime complains about the cyclic
dependency. Maybe I'm doing something weird without noticing? (I tried
it on 9.0.1, 9.0.4, 10, and 11-ea+7.)

 so long ... Nicolai



On 08.05.2018 11:05, Zheka Kozlov wrote:

> Hi Nicolai.
>
> I cannot reproduce what you said. I'm using JDK 10.0.1. I created two
> modules moduleA and moduleB which require each other. When I tried to
> compile, javac failed with an error: cyclic dependence involving module.
>
> Do you observer a different behavior?
>
> 2018-05-08 15:01 GMT+07:00 Nicolai Parlog <[hidden email]>:
>
>>  Hi!
>>
>> In early access builds, multi-module compilation would fail if there was
>> a dependency cycle between the involved modules. I just realized that
>> that is no longer the case in 9.0.1 and later (up to Java 11).
>>
>> I'm interested to learn the background for that decision? I considered
>> that check A Good Thing - why was it removed?
>>
>>  so long ... Nicolai
>>
>>
>>
>> --
>>
>> PGP Key:
>>     http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509
>>
>> Web:
>>     http://codefx.org
>>         a blog about software development
>>     https://www.sitepoint.com/java
>>         high-quality Java/JVM content
>>     http://do-foss.de
>>         Free and Open Source Software for the City of Dortmund
>>
>> Twitter:
>>     https://twitter.com/nipafx
>>
>

--

PGP Key:
    http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509

Web:
    http://codefx.org
        a blog about software development
    https://www.sitepoint.com/java
        high-quality Java/JVM content
    http://do-foss.de
        Free and Open Source Software for the City of Dortmund

Twitter:
    https://twitter.com/nipafx
Reply | Threaded
Open this post in threaded view
|

Re: Cyclic dependencies during multi-module compilation

Zheka Kozlov
Are you sure that you have a cycle between modules? You state that
"monitor.statistics depends on monitor.persistence", however I do not see
this in module-info.java:

module monitor.statistics {
requires monitor.observer;
exports monitor.statistics;
}


2018-05-08 16:34 GMT+07:00 Nicolai Parlog <[hidden email]>:

>  Hi Zheka,
>
> this branch demonstrates what I describe:
>
>         https://github.com/CodeFX-org/demo-jpms-monitor/tree/break-
> cyclic-dependency-compile-time
>
> Run `multi-compile.sh && run.sh` and you will see the compiler happily
> creating the modules whereas the runtime complains about the cyclic
> dependency. Maybe I'm doing something weird without noticing? (I tried
> it on 9.0.1, 9.0.4, 10, and 11-ea+7.)
>
>  so long ... Nicolai
>
>
>
> On 08.05.2018 11:05, Zheka Kozlov wrote:
> > Hi Nicolai.
> >
> > I cannot reproduce what you said. I'm using JDK 10.0.1. I created two
> > modules moduleA and moduleB which require each other. When I tried to
> > compile, javac failed with an error: cyclic dependence involving module.
> >
> > Do you observer a different behavior?
> >
> > 2018-05-08 15:01 GMT+07:00 Nicolai Parlog <[hidden email]>:
> >
> >>  Hi!
> >>
> >> In early access builds, multi-module compilation would fail if there was
> >> a dependency cycle between the involved modules. I just realized that
> >> that is no longer the case in 9.0.1 and later (up to Java 11).
> >>
> >> I'm interested to learn the background for that decision? I considered
> >> that check A Good Thing - why was it removed?
> >>
> >>  so long ... Nicolai
> >>
> >>
> >>
> >> --
> >>
> >> PGP Key:
> >>     http://keys.gnupg.net/pks/lookup?op=vindex&search=
> 0xCA3BAD2E9CCCD509
> >>
> >> Web:
> >>     http://codefx.org
> >>         a blog about software development
> >>     https://www.sitepoint.com/java
> >>         high-quality Java/JVM content
> >>     http://do-foss.de
> >>         Free and Open Source Software for the City of Dortmund
> >>
> >> Twitter:
> >>     https://twitter.com/nipafx
> >>
> >
>
> --
>
> PGP Key:
>     http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509
>
> Web:
>     http://codefx.org
>         a blog about software development
>     https://www.sitepoint.com/java
>         high-quality Java/JVM content
>     http://do-foss.de
>         Free and Open Source Software for the City of Dortmund
>
> Twitter:
>     https://twitter.com/nipafx
>
Reply | Threaded
Open this post in threaded view
|

Re: Cyclic dependencies during multi-module compilation

Nicolai Parlog
Here it is:

        https://github.com/CodeFX-org/demo-jpms-monitor/blob/break-cyclic-dependency-compile-time/monitor.statistics/src/main/java/module-info.java#L3

Maybe you looked at the master branch?



On 08.05.2018 12:11, Zheka Kozlov wrote:

> Are you sure that you have a cycle between modules? You state that
> "monitor.statistics depends on monitor.persistence", however I do not see
> this in module-info.java:
>
> module monitor.statistics {
> requires monitor.observer;
> exports monitor.statistics;
> }
>
>
> 2018-05-08 16:34 GMT+07:00 Nicolai Parlog <[hidden email]>:
>
>>  Hi Zheka,
>>
>> this branch demonstrates what I describe:
>>
>>         https://github.com/CodeFX-org/demo-jpms-monitor/tree/break-
>> cyclic-dependency-compile-time
>>
>> Run `multi-compile.sh && run.sh` and you will see the compiler happily
>> creating the modules whereas the runtime complains about the cyclic
>> dependency. Maybe I'm doing something weird without noticing? (I tried
>> it on 9.0.1, 9.0.4, 10, and 11-ea+7.)
>>
>>  so long ... Nicolai
>>
>>
>>
>> On 08.05.2018 11:05, Zheka Kozlov wrote:
>>> Hi Nicolai.
>>>
>>> I cannot reproduce what you said. I'm using JDK 10.0.1. I created two
>>> modules moduleA and moduleB which require each other. When I tried to
>>> compile, javac failed with an error: cyclic dependence involving module.
>>>
>>> Do you observer a different behavior?
>>>
>>> 2018-05-08 15:01 GMT+07:00 Nicolai Parlog <[hidden email]>:
>>>
>>>>  Hi!
>>>>
>>>> In early access builds, multi-module compilation would fail if there was
>>>> a dependency cycle between the involved modules. I just realized that
>>>> that is no longer the case in 9.0.1 and later (up to Java 11).
>>>>
>>>> I'm interested to learn the background for that decision? I considered
>>>> that check A Good Thing - why was it removed?
>>>>
>>>>  so long ... Nicolai
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> PGP Key:
>>>>     http://keys.gnupg.net/pks/lookup?op=vindex&search=
>> 0xCA3BAD2E9CCCD509
>>>>
>>>> Web:
>>>>     http://codefx.org
>>>>         a blog about software development
>>>>     https://www.sitepoint.com/java
>>>>         high-quality Java/JVM content
>>>>     http://do-foss.de
>>>>         Free and Open Source Software for the City of Dortmund
>>>>
>>>> Twitter:
>>>>     https://twitter.com/nipafx
>>>>
>>>
>>
>> --
>>
>> PGP Key:
>>     http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509
>>
>> Web:
>>     http://codefx.org
>>         a blog about software development
>>     https://www.sitepoint.com/java
>>         high-quality Java/JVM content
>>     http://do-foss.de
>>         Free and Open Source Software for the City of Dortmund
>>
>> Twitter:
>>     https://twitter.com/nipafx
>>
>

--

PGP Key:
    http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509

Web:
    http://codefx.org
        a blog about software development
    https://www.sitepoint.com/java
        high-quality Java/JVM content
    http://do-foss.de
        Free and Open Source Software for the City of Dortmund

Twitter:
    https://twitter.com/nipafx
Reply | Threaded
Open this post in threaded view
|

Re: Cyclic dependencies during multi-module compilation

Zheka Kozlov
Sorry. I switched to the branch and now I see the issue. Looks like a bug
for me.

2018-05-08 17:16 GMT+07:00 Nicolai Parlog <[hidden email]>:

> Here it is:
>
>         https://github.com/CodeFX-org/demo-jpms-monitor/blob/break-
> cyclic-dependency-compile-time/monitor.statistics/src/
> main/java/module-info.java#L3
>
> Maybe you looked at the master branch?
>
>
>
> On 08.05.2018 12:11, Zheka Kozlov wrote:
> > Are you sure that you have a cycle between modules? You state that
> > "monitor.statistics depends on monitor.persistence", however I do not see
> > this in module-info.java:
> >
> > module monitor.statistics {
> > requires monitor.observer;
> > exports monitor.statistics;
> > }
> >
> >
> > 2018-05-08 16:34 GMT+07:00 Nicolai Parlog <[hidden email]>:
> >
> >>  Hi Zheka,
> >>
> >> this branch demonstrates what I describe:
> >>
> >>         https://github.com/CodeFX-org/demo-jpms-monitor/tree/break-
> >> cyclic-dependency-compile-time
> >>
> >> Run `multi-compile.sh && run.sh` and you will see the compiler happily
> >> creating the modules whereas the runtime complains about the cyclic
> >> dependency. Maybe I'm doing something weird without noticing? (I tried
> >> it on 9.0.1, 9.0.4, 10, and 11-ea+7.)
> >>
> >>  so long ... Nicolai
> >>
> >>
> >>
> >> On 08.05.2018 11:05, Zheka Kozlov wrote:
> >>> Hi Nicolai.
> >>>
> >>> I cannot reproduce what you said. I'm using JDK 10.0.1. I created two
> >>> modules moduleA and moduleB which require each other. When I tried to
> >>> compile, javac failed with an error: cyclic dependence involving
> module.
> >>>
> >>> Do you observer a different behavior?
> >>>
> >>> 2018-05-08 15:01 GMT+07:00 Nicolai Parlog <[hidden email]>:
> >>>
> >>>>  Hi!
> >>>>
> >>>> In early access builds, multi-module compilation would fail if there
> was
> >>>> a dependency cycle between the involved modules. I just realized that
> >>>> that is no longer the case in 9.0.1 and later (up to Java 11).
> >>>>
> >>>> I'm interested to learn the background for that decision? I considered
> >>>> that check A Good Thing - why was it removed?
> >>>>
> >>>>  so long ... Nicolai
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>>
> >>>> PGP Key:
> >>>>     http://keys.gnupg.net/pks/lookup?op=vindex&search=
> >> 0xCA3BAD2E9CCCD509
> >>>>
> >>>> Web:
> >>>>     http://codefx.org
> >>>>         a blog about software development
> >>>>     https://www.sitepoint.com/java
> >>>>         high-quality Java/JVM content
> >>>>     http://do-foss.de
> >>>>         Free and Open Source Software for the City of Dortmund
> >>>>
> >>>> Twitter:
> >>>>     https://twitter.com/nipafx
> >>>>
> >>>
> >>
> >> --
> >>
> >> PGP Key:
> >>     http://keys.gnupg.net/pks/lookup?op=vindex&search=
> 0xCA3BAD2E9CCCD509
> >>
> >> Web:
> >>     http://codefx.org
> >>         a blog about software development
> >>     https://www.sitepoint.com/java
> >>         high-quality Java/JVM content
> >>     http://do-foss.de
> >>         Free and Open Source Software for the City of Dortmund
> >>
> >> Twitter:
> >>     https://twitter.com/nipafx
> >>
> >
>
> --
>
> PGP Key:
>     http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509
>
> Web:
>     http://codefx.org
>         a blog about software development
>     https://www.sitepoint.com/java
>         high-quality Java/JVM content
>     http://do-foss.de
>         Free and Open Source Software for the City of Dortmund
>
> Twitter:
>     https://twitter.com/nipafx
>
Reply | Threaded
Open this post in threaded view
|

Re: Cyclic dependencies during multi-module compilation

Alan Bateman
In reply to this post by Nicolai Parlog
On 08/05/2018 11:16, Nicolai Parlog wrote:
> Here it is:
>
> https://github.com/CodeFX-org/demo-jpms-monitor/blob/break-cyclic-dependency-compile-time/monitor.statistics/src/main/java/module-info.java#L3
>
> Maybe you looked at the master branch?
>
Would it be possible to package this up and send it as an attachment and
I'll create a bug for this.

-Alan
Reply | Threaded
Open this post in threaded view
|

Re: Cyclic dependencies during multi-module compilation

David Lloyd
In reply to this post by Nicolai Parlog
I still consider this to be a non-bug.  The cycle check has absolutely
no useful purpose other than "scratching an itch".

On Tue, May 8, 2018 at 3:01 AM, Nicolai Parlog <[hidden email]> wrote:

>  Hi!
>
> In early access builds, multi-module compilation would fail if there was
> a dependency cycle between the involved modules. I just realized that
> that is no longer the case in 9.0.1 and later (up to Java 11).
>
> I'm interested to learn the background for that decision? I considered
> that check A Good Thing - why was it removed?
>
>  so long ... Nicolai
>
>
>
> --
>
> PGP Key:
>     http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509
>
> Web:
>     http://codefx.org
>         a blog about software development
>     https://www.sitepoint.com/java
>         high-quality Java/JVM content
>     http://do-foss.de
>         Free and Open Source Software for the City of Dortmund
>
> Twitter:
>     https://twitter.com/nipafx



--
- DML
Reply | Threaded
Open this post in threaded view
|

Re: Cyclic dependencies during multi-module compilation

Nicolai Parlog
In reply to this post by Alan Bateman
 Hi Alan,

so just to get this straight, there should be a compile error, yes? I'm
sure there was one while Java 9 was in EA and now there isn't anymore,
which bugs the hell out of me because my book claims, there's going to
be one. :(

> Would it be possible to package this up and send it as an attachment
> and I'll create a bug for this.

You can download a ZIP for that branch here:

        https://github.com/CodeFX-org/demo-jpms-monitor/archive/break-cyclic-dependency-compile-time.zip

In case there could be legal issues, this code is licensed under CC0, so
you can do whatever you want with it. :)

 so long ... Nicolai



On 08.05.2018 12:40, Alan Bateman wrote:

> On 08/05/2018 11:16, Nicolai Parlog wrote:
>> Here it is:
>>
>>     https://github.com/CodeFX-org/demo-jpms-monitor/blob/break-cyclic-dependency-compile-time/monitor.statistics/src/main/java/module-info.java#L3
>>
>>
>> Maybe you looked at the master branch?
>>
> Would it be possible to package this up and send it as an attachment and
> I'll create a bug for this.
>
> -Alan
>

--

PGP Key:
    http://keys.gnupg.net/pks/lookup?op=vindex&search=0xCA3BAD2E9CCCD509

Web:
    http://codefx.org
        a blog about software development
    https://www.sitepoint.com/java
        high-quality Java/JVM content
    http://do-foss.de
        Free and Open Source Software for the City of Dortmund

Twitter:
    https://twitter.com/nipafx
Reply | Threaded
Open this post in threaded view
|

Re: Cyclic dependencies during multi-module compilation

Alan Bateman
On 09/05/2018 08:30, Nicolai Parlog wrote:
>   Hi Alan,
>
> so just to get this straight, there should be a compile error, yes? I'm
> sure there was one while Java 9 was in EA and now there isn't anymore,
> which bugs the hell out of me because my book claims, there's going to
> be one. :(
>
There seems to a subtle bug in javac where the cycle detection depends
on the ordering of the `requires` directives. I've created JDK-8202832
[1] to track this. The bug duplicates with JDK 9 (and JDK 10 and current
JDK 11 EA builds). You may be right that it failed correctly with older
JDK 9 EA builds but I haven't checked yet if that is the case.

-Alan

[1] https://bugs.openjdk.java.net/browse/JDK-8202832