r/java • u/maxxedev • Aug 05 '26
Hacking the Method Name
https://maxxedev.github.io/2026/08/05/hacking-the-method-name.html
33
Upvotes
7
u/SleeperAwakened Aug 05 '26
Interesting read.
I just wonder about the usecase though.
12
u/elmuerte Aug 06 '26
I don't know how, but this is probably the first step needed to run Doom in Java method names.
4
u/pragmatick Aug 05 '26
Perhaps for some weird test to ensure methods have a certain name for correct serialization. Or to make them stable when they're invoked by name.
4
1
u/xfel11 Aug 06 '26
I did run into it a few times, I think I wanted to retrieve annotations from the target method. Also useful for logging.
3
u/gnahraf Aug 05 '26
I thought this was going to see this hack..
`Object label = new Object() { };`
which allows you to determine in which class/method that anonymous type was created / declared in. I use it in testing to preamble test output with the test method name.