Fun with Java annotations

I was at Jfokus earlier this February, and I attended the presentation The definitive guide to Java agents, you can watch the recorded video and view the presentation.
The speaker, Rafael Winterhalter, gave an introduction to Java agents, and how his library Byte Buddy helped overcoming the quite cumbersome way to write Java agents.
I was inspired to tinker some with Java annotations, and writing a small program to see if I could write something to make me able to annotate functions, requiring that the caller to meet the set requirement roles. After some experimentation, I understood the basic principles, and made it a bit more complete by storing the callers roles in a ThreadLocal storage, so they don't have to be passed along through all the method calls.
You check out my experiment on github. Consider it a POC or inspiration, it's not complete or is a real agent, at least not at the moment of writing this blog.
Playing with Byte Buddy was quite fun, so I will dabble with it more in the future, perhaps making a proper agent, perhaps write some more demonstration like material.
2020-02-21Kenneth HedmanEnglishJavaprogramming