You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] PublicMemberInNonPublicType: False positive for main(...) methods #6459
changed the title [-]PublicMemberInNonPublicType should ignore `main` methods[/-][+]`PublicMemberInNonPublicType` should ignore `main` methods[/+]on Feb 15, 2026
changed the title [-]`PublicMemberInNonPublicType` should ignore `main` methods[/-][+][java] PublicMemberInNonPublicType: False positive for `main(...)` methods[/+]on Feb 16, 2026
Activity
uhafner commentedon Feb 15, 2026
BTW: In order to ignore the violation I need to suppress on the type and not on the affected method, it would be nice if that can be changed as well.(As shown in https://github.com/jenkinsci/analysis-model/blob/666ae125babdfb716e5c1c5198acf01559a7f008/src/test/java/edu/hm/hafner/analysis/IssueTest.java#L362 this works for methods)[-]PublicMemberInNonPublicType should ignore `main` methods[/-][+]`PublicMemberInNonPublicType` should ignore `main` methods[/+][-]`PublicMemberInNonPublicType` should ignore `main` methods[/-][+][java] PublicMemberInNonPublicType: False positive for `main(...)` methods[/+]UncleOwen commentedon Jun 21, 2026
Is this really a false positive?
In Java < 25 (ignoring previews), this isn't a valid entry point.
In Java >= 25, you can write this as
or even
In both cases, I'd say that the warning is justified?
uhafner commentedon Jun 21, 2026
It is a valid entry point in Java < 25. Why should this not be possible?
I am using this part in a lot of my test cases, example: https://github.com/jenkinsci/analysis-model/blob/666ae125babdfb716e5c1c5198acf01559a7f008/src/test/java/edu/hm/hafner/analysis/IssueTest.java#L362
UncleOwen commentedon Jun 21, 2026
Huh. I could have sworn that main had to be in a public class in java < 25. You're right, I was wrong. This is indeed valid.
PublicMemberInNonPublicType: Don't trigger on main method (#6459)
[java] Fix #6459: special case main in PublicMemberInNonPublicType (#…