Main Method Reserved
ID |
java.main_method_reserved |
Severity |
info |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Code Smell |
Language |
Java |
Tags |
code-style |
Description
Reports methods named main whose signature does not match the standard entry-point signature public static void main(String[]).
Rationale
The name main is reserved by convention for the application entry point. Using it for a non-standard method confuses IDEs, build tools, and container launchers that look for the canonical signature. It also misleads developers who expect main to be the program’s starting point.
// Bad -- non-standard main methods
public static void main() { } // no parameter
public static int main(String[] args) { return 0; } // wrong return type
public void main(String[] args) { } // not static