Searching for final methods in a Java project

Efficient way to find final methods in a Java project

Quick tip of the day: searching for final methods in a Java project.

Recently at work, I had to find all final methods in a codebase.

The following regular expression helped me out:

(public|protected|private|static|\\s) (final) +\[\\w\\<\\>\\\[\\\]\]+\\s+(\\w+) \*\\(\[^\\)\]\*\\) \*(\\{?|\[^;\])

For the curious among you, I needed to do this because of an issue where some Spring bean mysteriously had null properties. The issue was caused by the fact that we had final methods in some beans that CGLib did not like (i.e., could not proxy).

That's it for today! ✨