Sébastien Dubois
1 min readMay 23, 2019

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 😉

Sébastien Dubois
Sébastien Dubois

Written by Sébastien Dubois

PKM Systems Architect Helping Knowledge Workers save 10+ hours/week 1K+ Happy customers ❤️ 🚀 https://developassion.gumroad.com 💌 https://dSebastien.net

No responses yet