Javac ignores module-info dependencies

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

Javac ignores module-info dependencies

Mike Ershov
Hello,

I noticed that javac does not take requires part of module-info as
compile class path. Is it correct behavior?
I have sources for two modules under one source root -
m1 and m2. m2 uses class from m1 but m2's module-info has no "requires
m1" statement. I expected compile-time error, but a compilation is
successful and I see runtime error. The code is attached.

Sorry in advance if this is known issue.

Thanks,
Mike

Reply | Threaded
Open this post in threaded view
|

Re: Javac ignores module-info dependencies

Mike Ershov
Sorry for inconvenience, trying to resend with attachment.

Mike

Mike Ershov wrote:

> Hello,
>
> I noticed that javac does not take requires part of module-info as
> compile class path. Is it correct behavior?
> I have sources for two modules under one source root -
> m1 and m2. m2 uses class from m1 but m2's module-info has no "requires
> m1" statement. I expected compile-time error, but a compilation is
> successful and I see runtime error. The code is attached.
>
> Sorry in advance if this is known issue.
>
> Thanks,
> Mike
>

Reply | Threaded
Open this post in threaded view
|

Re: Javac ignores module-info dependencies

Mike Ershov
Sorry again, attachments are prohibited here. The code:

==== files
./make.sh
./srcmod/mod2/p2/Main.java
./srcmod/mod2/module-info.java
./srcmod/mod1/p1/C.java
./srcmod/mod1/module-info.java

==== make.sh
#!/bin/sh
JIGSAW=/opt/java/j8/bin
SRC=srcmod/

rm -rf classes
mkdir classes
rm -rf mlib

$JIGSAW/jmod create -L mlib
$JIGSAW/javac -d classes -modulepath mlib -sourcepath $SRC `find $SRC
-name '*.java'`
$JIGSAW/jpkg -m classes/mod1 jmod mod1
$JIGSAW/jpkg -m classes/mod2 jmod mod2
$JIGSAW/jmod install -L mlib [hidden email]
$JIGSAW/jmod install -L mlib [hidden email]
$JIGSAW/java -L mlib -m mod2

==== srcmod/mod1/module-info.java
module mod1 @1.0 {
    requires jdk.base;
}

==== srcmod/mod1/p1/C.java
package p1;

public class C {
   public void say() {
      System.out.println("Hello, bug!");
   }
}

==== srcmod/mod2/module-info.java
module mod2 @1.0 {
    requires jdk.base;
    class p2.Main;
}

==== srcmod/mod2/p2/Main.java
package p2;
import p1.C;

public class Main {
   public static void main(String[] args) {
      new C().say();
   }
}



Mike Ershov wrote:

> Sorry for inconvenience, trying to resend with attachment.
>
> Mike
>
> Mike Ershov wrote:
>> Hello,
>>
>> I noticed that javac does not take requires part of module-info as
>> compile class path. Is it correct behavior?
>> I have sources for two modules under one source root -
>> m1 and m2. m2 uses class from m1 but m2's module-info has no "requires
>> m1" statement. I expected compile-time error, but a compilation is
>> successful and I see runtime error. The code is attached.
>>
>> Sorry in advance if this is known issue.
>>
>> Thanks,
>> Mike
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Javac ignores module-info dependencies

Jonathan Gibbons
In reply to this post by Mike Ershov
Mike,

Sorry, known issue. I've been waiting for the visibility and
accessibility discussions to wind down before implementing the rules in
javac.

-- Jon

On 01/24/2012 05:40 AM, Mike Ershov wrote:

> Hello,
>
> I noticed that javac does not take requires part of module-info as
> compile class path. Is it correct behavior?
> I have sources for two modules under one source root -
> m1 and m2. m2 uses class from m1 but m2's module-info has no "requires
> m1" statement. I expected compile-time error, but a compilation is
> successful and I see runtime error. The code is attached.
>
> Sorry in advance if this is known issue.
>
> Thanks,
> Mike
>