r/java • u/RevilTS • Aug 03 '25
Teach Me the Craziest, Most Useful Java Features — NOT the Basic Stuff
I want to know the WILD, INSANELY PRACTICAL, "how the hell did I not know this earlier?" kind of Java stuff that only real devs who've been through production hell know.
Like I didn't know about modules recently
393
Upvotes
View all comments
10
u/agentoutlier Aug 03 '25 edited Aug 03 '25
Annotations.
You can process them at compile time and generate new code in the same compile process.
You can access them with reflection.
They can even be put them on types so you extend the type system.
They can be used for declarative configuration and yet more typesafe than what is in other languages.
They can show up in documentation if you like.
No other language I know has anything similar to the same power. They may have something similar but not all the features.
EDIT /u/MemerinoPanYVino
For those looking for example annotation processors: https://github.com/gunnarmorling/awesome-annotation-processing
For those looking for example type extension: https://checkerframework.org/