Java doesn't have the concept of Subpackage visibility
I know that :(
Java: Subpackage visibility?
so if I have a Class A (package visible) inside the package com.example.foo
and another Class B (package visible) inside the package com.example.foo.bar
+-- org.example
|
+-- foo
|
+-- A
|
+-- bar
|
+-- B
they are like actually in different packages and then one class is not visible from the other.
One thing that I always like to know is the WHY?
The structure folder of the package would encourage a mechanism like subpackage visibility.
So that the Class with higher hierarchy can access to the one with lower hierarchy.
In this example:
Class A should be able to access to Class B
(Similarly to that happen to the inner classes)
If that mechanism would be in place we could organize better our code and have better incapsulation.
How to organize code logically into package while preserving encapsulation
This would be a very nice feature for the Java world.
Without wanting to criticize, why has been taken that kind of decision for the package visible?
And why the Subpackage visibility is not taking into consideration?