Attempt to attach zip failed. Attaching the same content as a patch files.diff. It can be "extracted" by invoking:

   hg init

   hg import files.diff -m comments

On 18.05.2016 18:16, Jonathan Gibbons wrote:
Without yet looking at your zip file, it is possible to compile classes that will not load in the application class loader, because of the restrictions defined for the boot layer. That does not imply the classes themselves are invalid, since they can be loaded and run in suitable configured layers/classloaders.

-- Jon


On 05/18/2016 05:53 AM, Georgiy Rakov wrote:

Hello Jon,

we've encountered situation when class files resulted from successful compilation cause runtime error; the sources are compiled by single javac invocation. This looks like incorrect javac behavior, namely it seems that javac should produce compile-time error if one tries to compile sources which will cause error at runtime. Could you please confirm if it's really is.

More details are provided in the forwarded message below. I have also attached an archive with minimized testcase and scripts to run it. In order to run it please:

1. Unzip attached archive to some machine (Windows or Unix);

2. If it's Windows rename test18/test_bat to test18/test.bat.

3. Modify JDK_HOME variable inside test18/test.bat (or test18/test.sh) to point to your JDK installation.

4. Run test18/test.bat (or test18/test.sh).

Thank you,

Georgiy.



-------- Forwarded Message --------
Subject:        Re: Modules with packages duplication
Date:   Thu, 05 May 2016 18:21:20 +0300
From:   Konstantin Barzilovich <konstantin.barzilov...@oracle.com>
Organization:   Oracle Corporation
To: ML OpenJDK Jigsaw Developers <jigsaw-dev@openjdk.java.net>, Alan Bateman <alan.bate...@oracle.com>



Hello Alan,

Thank you for the answer.

I have one more question connected with duplication of packages.
Now we can compile two modules with the duplicated package without compile-time 
error if there is no module which can access both of them.
But in case of these two modules are readable by third module, in runtime it 
will result in error of boot Layer, as you said.
Is it okey, that compiler allow us to compile code, that will cause runtime 
failure?

Here is minimal test case:
------------------------------
module1/module-info.java
module module1 {
      exports pack;
}

module1/pack/A.java:
package pack;
public class A{}

module2/module-info.java
module module2 {
}

module2/pack/A.java:
package pack;
public class A{}

module3/module-info.java:
module module3{
      requires module1;
      requires module2;
}

Thanks,
Konstantin.

>
> On 04/05/2016 14:18, Konstantin Barzilovich wrote:
>> Hello,
>>
>> I can see that RI checks if there are packages with the same names in >> 
different modules (named or unnamed).
>> This check fails even if there is no clash (no module can read both >> 
packages).
>> Will it be the same in final version of JDK9 or it can be changed soon?
>>
> I think you are asking about modules on the application module path > (`java -modulepath ...`) 
that are resolved at startup. These are defined > to the application class loader so they cannot have 
overlapping > packages. It's trivial to do things like map each module in its own > class loader but 
that messes with visibility with lots of implications > (particularly when running with both a class 
path and module path or > where you bringing automatic modules into the picture). So what you are > 
seeing is specific to the boot Layer and no specific short term plans to > change this.
>
> -Alan


diff -r 000000000000 -r 73c08b4cf501 module1/module-info.java
--- /dev/null
+++ b/module1/module-info.java
@@ -0,0 +1,3 @@
+module module1 {
+    exports pack;
+}
diff -r 000000000000 -r 73c08b4cf501 module1/pack/A.java
--- /dev/null
+++ b/module1/pack/A.java
@@ -0,0 +1,3 @@
+package pack;
+
+public class A{}
diff -r 000000000000 -r 73c08b4cf501 module2/module-info.java
--- /dev/null
+++ b/module2/module-info.java
@@ -0,0 +1,2 @@
+module module2 {
+}
diff -r 000000000000 -r 73c08b4cf501 module2/pack/A.java
--- /dev/null
+++ b/module2/pack/A.java
@@ -0,0 +1,3 @@
+package pack;
+
+public class A{}
diff -r 000000000000 -r 73c08b4cf501 module3/mainpack/Main.java
--- /dev/null
+++ b/module3/mainpack/Main.java
@@ -0,0 +1,7 @@
+package mainpack;
+
+public class Main {
+       public static void main(String args[]) {
+               System.out.println("Hello world");
+       }
+}
\ No newline at end of file
diff -r 000000000000 -r 73c08b4cf501 module3/module-info.java
--- /dev/null
+++ b/module3/module-info.java
@@ -0,0 +1,5 @@
+module module3{
+    requires module1;
+    requires module2;
+       exports mainpack;
+}
\ No newline at end of file
diff -r 000000000000 -r 73c08b4cf501 test.bat
--- /dev/null
+++ b/test.bat
@@ -0,0 +1,21 @@
+@echo off
+set JDK_HOME=
+set JDK_BIN=%JDK_HOME%\bin
+set JAVAC=%JDK_BIN%\javac
+set JAVA=%JDK_BIN%\java
+set CUR_DIR=%~dp0
+set OUT_DIR=%CUR_DIR%out
+set FILES=module1\module-info.java^
+ module1\pack\A.java^
+ module2\module-info.java^
+ module2\pack\A.java^
+ module3\module-info.java^
+ module3\mainpack\Main.java
+
+rmdir %OUT_DIR% /S /Q
+mkdir %OUT_DIR%
+
+@echo on
+
+%JAVAC% -d %OUT_DIR% -modulesourcepath %CUR_DIR% %FILES%
+%JAVA% -modulepath %OUT_DIR% -m module3/mainpack.Main
\ No newline at end of file
diff -r 000000000000 -r 73c08b4cf501 test.sh
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,26 @@
+#!/usr/ccs/bin/bash
+JDK_HOME=
+JDK_BIN=$JDK_HOME/bin
+JAVAC=$JDK_BIN/javac
+JAVA=$JDK_BIN/java
+CUR_DIR=${0%/*}
+OUT_DIR=$CUR_DIR/out
+MSP=$CUR_DIR/test/modules
+FILES="module1/module-info.java \
+ module1/pack/A.java \
+ module2/module-info.java \
+ module2/pack/A.java \
+ module3/module-info.java
+ module3/mainpack/Main.java"
+  
+rm -rf $OUT_DIR
+mkdir $OUT_DIR
+
+JAVAC_INVOCATION="$JAVAC -d $OUT_DIR -modulesourcepath $CUR_DIR $FILES"
+JAVA_INVOCATION="$JAVA -modulepath $OUT_DIR -m module3/mainpack.Main"
+
+#echo $JAVAC_INVOCATION
+$JAVAC_INVOCATION
+
+#echo $JAVA_INVOCATION
+$JAVA_INVOCATION

Reply via email to