Reputation: 411
I have a project P1 that has a package A.B.C within which there is a class MyClass1. This class has default scope. Because of this, it is not visible in any of the other packages within project P1 and certainly not visible to any other project.
However, if I create another project P2 that has a package with the same name A.B.C, I can access the class MyClass1. This sounds bad because any one who wants to use the unexposed API can just create a package with a same name and get the access.
Is this the expected behavior?
--
Another related question: Is there anything in Java for project level scope?
Upvotes: 1
Views: 872
Reputation: 117685
Is this the expected behavior?
Yes. That's why you cannot name your package with java.*
.
Is there anything in Java for project level scope?
No.
Upvotes: 6