<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hello Karan,</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I believe the existing documentation and specification is correct in this aspect.</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
In Java Language Specification, Section 12.1.2 [1], and Java Virtual Machine Specification, Section 5.2 [2], both state that the initial class is initialized before main is invoked.</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
JLS:</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
> After Test is loaded, it must be initialized before main can be invoked.</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
JVMS:</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
> The Java Virtual Machine then links the initial class or interface, initializes it, and invokes the public static method void main(String[])</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
In particular, JLS 12.1.3 describes the execution of initializers for the main class, including static initializers. JLS 12.1.4 then describes the execution of the main method, which happens after the execution of the class initializer.</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
It might be the "guideline" that you found somewhere was unofficial and misrepresented the Java specifications.</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
P.S. You are mailing to the OpenJDK organization instead of Oracle. This list jdk-dev is for development information relevant to all parts of the JDK project in the OpenJDK question. If you have any question, please reply to me privately without cc'ing to this
 list.</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Regards,</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Chen</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
[1] <a href="https://docs.oracle.com/javase/specs/jls/se24/html/jls-12.html#jls-12.1.2" id="OWA01e29203-2794-58bf-92fb-47a24e32bb42" class="OWAAutoLink">
https://docs.oracle.com/javase/specs/jls/se24/html/jls-12.html#jls-12.1.2</a></div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
[2] <a href="https://docs.oracle.com/javase/specs/jvms/se24/html/jvms-5.html#jvms-5.2" id="OWAd14cbe12-cf70-c925-743b-787a89c7329e" class="OWAAutoLink">
https://docs.oracle.com/javase/specs/jvms/se24/html/jvms-5.html#jvms-5.2</a></div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> jdk-dev <jdk-dev-retn@openjdk.org> on behalf of Karan Sharma <karan03945@gmail.com><br>
<b>Sent:</b> Wednesday, April 30, 2025 6:05 PM<br>
<b>To:</b> jdk-dev@openjdk.org <jdk-dev@openjdk.org><br>
<b>Subject:</b> Clarification Regarding Java Program Entry Point and Static Block Execution</font>
<div> </div>
</div>
<div>
<div dir="auto">Dear Oracle Java Documentation Team,
<div dir="auto"><br>
</div>
<div dir="auto">I hope this message finds you well.</div>
<div dir="auto"><br>
</div>
<div dir="auto">I have been studying Java and came across the commonly stated guideline that the main(String[] args) method serves as the entry point for all Java applications. However, during experimentation and further reading, I observed that static blocks
 in a Java class are executed before the main() method, and in some cases, it is even possible to run logic using only static blocks without defining a main() method (such as in earlier versions of Java or with specific class loaders).</div>
<div dir="auto"><br>
</div>
<div dir="auto">This leads me to a conceptual query:</div>
<div dir="auto">If static blocks are executed prior to main(), and code within them can run independently, is it still fully accurate to say that the main method is the only entry point of a Java program?</div>
<div dir="auto"><br>
</div>
<div dir="auto">I understand that main() serves as the starting point for execution in standard standalone Java applications. However, since there are cases (e.g., static initialization, frameworks, reflection) where control can begin before or without main(),
 I believe it may be valuable to clarify this nuance in the official documentation — especially for learners trying to deeply understand Java's execution model.</div>
<div dir="auto"><br>
</div>
<div dir="auto">I would greatly appreciate any insights or thoughts from your side on this topic.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Thank you for maintaining such comprehensive resources for Java developers worldwide.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Warm regards,</div>
<div dir="auto">Karan Kumar</div>
<div dir="auto"><a href="mailto:karan03945@gmail.com">karan03945@gmail.com</a></div>
<div dir="auto">B.Tech Student | Java Enthusiast</div>
</div>
</div>
</body>
</html>