On 09/14/2015 11:14 AM, Alan Bateman wrote:
On 14/09/2015 09:22, Peter Levart wrote:
:

Gives the following runtime error:

Exception in thread "main" java.lang.IllegalAccessError: class pkgA.TestA (in module: modA) cannot access class pkgC.TypeC (in module: modC), modA cannot read modC
        at pkgA.TestA.main(modA@/TestA.java:8)


Which is expected. What I didn't expect is that javac did not figure this out correctly. Am I missing something and not using javac in the right way?

The API exported by modB has a method that returns an instance of pkgC.TypeC so I would have expected modB to be a good citizen and "requires public modC". Similarly, with the API exported by modC where is returns an instance of pkgD.TypeD, I would have expected modC to "requires public modD". I will guess that you've set it up this way to probe more into implied readability.

That's right. I checked whether the implied readability is transitive. It looks like it is, which is what I have expected.


The javac command looks right, I see that it also doesn't fail when the modules are compiled separately (D, C, B, A).

-Alan.

So this must be a javac bug, right?

Regards, Peter

Reply via email to