-
Bug
-
Resolution: Duplicate
-
P2
-
9
If 'exports' statement uses package name, then this package should be observable (contain compilation unit in it or in subpackages) and contain file with package declaration due to assertion jigsaw-1.1.2-210:
If the named package is observable in the current module, then at least one compilation unit containing a declaration of the package must be observable in the current module, or a compile-time error occurs.
So compile-time error is expected if
1) there is empty file (without package declaration) or
2) there is file with wrong package statement
in the package, but there is file in subpackage. But no error occurs.
--------------------------
Minimal case:
Directory layout:
mod1/module-info.java
mod1/p/B.java
mod1/p/q/A.java
Code:
module-info.java:
{code}
module mod1{
exports p;
}
{/code}
A.java:
{code}
package p.q;
class A { }
{/code}
1st example:
-----
B.java:
// no code here
-----
2nd example:
B.java:
{code}
package wrong;
{/code}
If the named package is observable in the current module, then at least one compilation unit containing a declaration of the package must be observable in the current module, or a compile-time error occurs.
So compile-time error is expected if
1) there is empty file (without package declaration) or
2) there is file with wrong package statement
in the package, but there is file in subpackage. But no error occurs.
--------------------------
Minimal case:
Directory layout:
mod1/module-info.java
mod1/p/B.java
mod1/p/q/A.java
Code:
module-info.java:
{code}
module mod1{
exports p;
}
{/code}
A.java:
{code}
package p.q;
class A { }
{/code}
1st example:
-----
B.java:
// no code here
-----
2nd example:
B.java:
{code}
package wrong;
{/code}
- duplicates
-
JDK-8144342 javac doesn't report errors if module exports non-existent package
- Resolved
- relates to
-
JDK-8130386 Package observability ascertainment still depends on side effects.
- Closed
-
JDK-8149658 follow up of JDK-8144342, add additional test case
- Resolved