Program logical organization (such as namespaces and packages) different from the distribution method during deployment (such as assembly and jar package), should the mutual access permissions of different classes be restricted in logical organization or physical distribution?
| JAVA |
language |
the logical organization mode is restricted, that is, you can access Java. the private classes in Lang can be compiled, as long as your Code is also in Java. lang is the package name [I guess, I have never tried] |
| runtime |
the physical distribution method is restricted, which may be related to the default classloader, even if you have compiled, but the classes under the same package are divided into different jar packages during deployment, access to private classes may fail [I guess, not tried] |
| . Net |
CLS |
I don't know. I want to add it |
| C # |
restrict the physical distribution method, that is, the assembly, from language to runtime |
I personally prefer C # permission control, which is reasonable and flexible. in Java, when the logic is different from the physical organization, it is not forced to move a class to the current package, that is, it is declared as public, once declared as public, you can no longer control it.
Traditional access control is beyond the scope of the language and is a platform feature.