[Question] Java 9 module-source-path inconsistency vs javac?

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

[Question] Java 9 module-source-path inconsistency vs javac?

Ryan Ulch
I’m attempting to integrate Java 9 support in a tool of ours in which we call the batch compiler directly. I’m not on a public release or anything — I’ve simply been merging in the BETA_JAVA9 branch periodically to our own branch (so basically, origin/master + origin/BETA_JAVA9 merged @ e3cdffd + some small customizations of our own that I don’t have a reason to believe would impact the issue I’m hitting).

Today, I stumbled upon a situation where the Eclipse compiler appears to be doing the wrong thing (at least relative to javac). I’m not yet sure if this is a configuration issue.

The source files I am compiling:

$ find src -name "*.java" -exec sh -c "echo File @ {}:; cat {};echo;" \;
File @ src/com.bar/module-info.java:
module com.bar {
    exports com.bar.foo;
}

File @ src/com.bar/com/bar/foo/Baz.java:
package com.bar.foo;

public class Baz
{}

File @ src/com.qux/module-info.java:
module com.qux {
    requires com.bar;
}

File @ src/com.qux/com/qux/Main.java:
package com.qux;

import com.bar.foo.Baz;

public class Main {
    public static void main(String[] args) {
        Baz b;
        System.out.println("Greetings!");
    }
}

Javac usage:

$ javac --version
javac 9
$ find . -name *.class
// meant to show no class files present before javac compilation
$ ./compile.sh
+++ find src/com.qux -name '*.java'
++ javac -d mods --module-source-path src src/com.qux/module-info.java src/com.qux/com/qux/Main.java
$ find . -name *.class
./mods/com.bar/module-info.class
./mods/com.bar/com/bar/foo/Baz.class
./mods/com.qux/module-info.class
./mods/com.qux/com/qux/Main.class

I’ve purposefully only explicitly added the files under src/com.qux  to the javac command line, and I am showing here that the javac is pulling in the com.bar module dependency via the module-source-path (as opposed to files explicitly on the command line).

Coming to the Eclipse side of this, I’m calling the batch compiler with the following arguments:

Eclipse args: [-noExit, -d, /tmp/cov-rulch/03ad347794789546c58ae5ae31f0a385, -s, /tmp/cov-rulch/03ad347794789546c58ae5ae31f0a385/gensrcc825493a96fe15d79f88a61ad936b0c2, -warn:-unused, -source, 9, -9, --module-source-path, src, --system, /data00/rulch/testing/java9/jdk-9, src/com.qux/module-info.java, src/com.qux/com/qux/Main.java]


And the batch compiler spits out these errors when invoked:

----------
1. ERROR in /data00/rulch/testing/java9/module-source-path/src/com.qux/com/qux/Main.java (at line 3)
        import com.bar.foo.Baz;
               ^^^^^^^^^^^^^^^
The import com.bar.foo.Baz cannot be resolved
----------
2. ERROR in /data00/rulch/testing/java9/module-source-path/src/com.qux/com/qux/Main.java (at line 7)
        Baz b;
        ^^^
Baz cannot be resolved to a type
----------
----------
3. ERROR in /data00/rulch/testing/java9/module-source-path/src/com.bar/com/bar/foo/Baz.java (at line 1)
        package com.bar.foo;
                ^^^^^^^^^^^
The package com.bar.foo conflicts with a package accessible from another module: com.bar
----------
3 problems (3 errors)

It’s also worth noting that if I add src/com.bar/com/bar/foo/Baz.java and src/com.bar/module-info.java to the command line, there are no errors, so this leads me to believe that this is a shortcoming in the current implementation.

Perhaps this is a configuration issue — if anyone has any feedback on this, I would appreciate it. I wasn’t able to find an open bug on the Eclipse Bugzilla that seemed to be explicitly for this issue — though there are open related bugs. I was hesitant to attempt to post there (I'm not even sure if I would have permissions to do so), so I’m just posting here first. I understand that it’s a beta – I just wanted to be sure there was some visibility on this possible behavior difference since it appears that the Eclipse developers attempt to mimic javac as closely as possible.

/Ryan


_______________________________________________
jdt-core-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jdt-core-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Question] Java 9 module-source-path inconsistency vs javac?

Daniel Megert
Hi Ryan

This might or might not be a big. javac is not a specification but a reference implementation of the spec, like ECJ. Please file a bug report against JDT Core and we will have a look.

Dani



From:        Ryan Ulch <[hidden email]>
To:        "[hidden email]" <[hidden email]>
Date:        27.09.2017 01:01
Subject:        [jdt-core-dev] [Question] Java 9 module-source-path inconsistency        vs javac?
Sent by:        [hidden email]




I’m attempting to integrate Java 9 support in a tool of ours in which we call the batch compiler directly. I’m not on a public release or anything — I’ve simply been merging in the BETA_JAVA9 branch periodically to our own branch (so basically, origin/master + origin/BETA_JAVA9 merged @ e3cdffd + some small customizations of our own that I don’t have a reason to believe would impact the issue I’m hitting).

Today, I stumbled upon a situation where the Eclipse compiler appears to be doing the wrong thing (at least relative to javac). I’m not yet sure if this is a configuration issue.

The source files I am compiling:

$ find src -name "*.java" -exec sh -c "echo File @ {}:; cat {};echo;" \;
File @ src/com.bar/module-info.java:
module com.bar {
    exports com.bar.foo;
}

File @ src/com.bar/com/bar/foo/Baz.java:
package com.bar.foo;

public class Baz
{}

File @ src/com.qux/module-info.java:
module com.qux {
    requires com.bar;
}

File @ src/com.qux/com/qux/Main.java:
package com.qux;

import com.bar.foo.Baz;

public class Main {
    public static void main(String[] args) {
        Baz b;
        System.out.println("Greetings!");
    }
}

Javac usage:

$ javac --version
javac 9
$ find . -name *.class
// meant to show no class files present before javac compilation
$ ./compile.sh
+++ find src/com.qux -name '*.java'
++ javac -d mods --module-source-path src src/com.qux/module-info.java src/com.qux/com/qux/Main.java
$ find . -name *.class
./mods/com.bar/module-info.class
./mods/com.bar/com/bar/foo/Baz.class
./mods/com.qux/module-info.class
./mods/com.qux/com/qux/Main.class

I’ve purposefully only explicitly added the files under src/com.qux  to the javac command line, and I am showing here that the javac is pulling in the com.bar module dependency via the module-source-path (as opposed to files explicitly on the command line).

Coming to the Eclipse side of this, I’m calling the batch compiler with the following arguments:

Eclipse args: [-noExit, -d, /tmp/cov-rulch/03ad347794789546c58ae5ae31f0a385, -s, /tmp/cov-rulch/03ad347794789546c58ae5ae31f0a385/gensrcc825493a96fe15d79f88a61ad936b0c2, -warn:-unused, -source, 9, -9, --module-source-path, src, --system, /data00/rulch/testing/java9/jdk-9, src/com.qux/module-info.java, src/com.qux/com/qux/Main.java]


And the batch compiler spits out these errors when invoked:

----------
1. ERROR in /data00/rulch/testing/java9/module-source-path/src/com.qux/com/qux/Main.java (at line 3)
        import com.bar.foo.Baz;
               ^^^^^^^^^^^^^^^
The import com.bar.foo.Baz cannot be resolved
----------
2. ERROR in /data00/rulch/testing/java9/module-source-path/src/com.qux/com/qux/Main.java (at line 7)
        Baz b;
        ^^^
Baz cannot be resolved to a type
----------
----------
3. ERROR in /data00/rulch/testing/java9/module-source-path/src/com.bar/com/bar/foo/Baz.java (at line 1)
        package com.bar.foo;
                ^^^^^^^^^^^
The package com.bar.foo conflicts with a package accessible from another module: com.bar
----------
3 problems (3 errors)

It’s also worth noting that if I add src/com.bar/com/bar/foo/Baz.java and src/com.bar/module-info.java to the command line, there are no errors, so this leads me to believe that this is a shortcoming in the current implementation.

Perhaps this is a configuration issue — if anyone has any feedback on this, I would appreciate it. I wasn’t able to find an open bug on the Eclipse Bugzilla that seemed to be explicitly for this issue — though there are open related bugs. I was hesitant to attempt to post there (I'm not even sure if I would have permissions to do so), so I’m just posting here first. I understand that it’s a beta – I just wanted to be sure there was some visibility on this possible behavior difference since it appears that the Eclipse developers attempt to mimic javac as closely as possible.

/Ryan
_______________________________________________
jdt-core-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://urldefense.proofpoint.com/v2/url?u=https-3A__dev.eclipse.org_mailman_listinfo_jdt-2Dcore-2Ddev&d=DwICAg&c=jf_iaSHvJObTbx-siA1ZOg&r=1UITCR5rxUZHSFczvfaNFK4ymEbEiccRX7VKchpqz0Y&m=HrahjGcKFMpKp85TH_sdVLhcsIaX4cUE_-sE0ioPPak&s=z5DqR8vo0jHWJiL2Wd9i_YBWBuriaDuIBe1HjQWzSvA&e=



_______________________________________________
jdt-core-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jdt-core-dev