Introduction - If you have any usage issues, please Google them yourself
This example shows the ability of Java to declaratively restrict access to certain packages when run with SecurityManager.
By default, access to classes in "sun.*" packages is restricted. However, since Java runs without SecurityManager by default, these checks may not be always performed.
An explanation of example:
1. RestrictedPackageAccess class creates and calls sun.misc.BASE64Encoder
2. First, the default execution happens without SecurityManager, and everything is permitted
3. Secondly, SecurityManager is enabled, and the code doesn t pass the security check
4. However, when the code is run with a different policy, that allows access, the excution goes fine again.