Consider the following code, where the HelloWorld
class has default or package-private access:
class HelloWorld {
public static void main(St
JVM startup is described in §12.1 Virtual Machine Start-Up of the JLS.
Note that this chapter says nothing about visibility checks with regards to the class. It only specifies that the main
method must be public
.
This means that there simply is no check for visibility on the class level (which kind-of makes sense as there is no context yet against which to check the visibility: in which "package" is the "caller"?).