So compile-time annotation processing is as old as the annotations themselves in Java. Yet most of the useful libraries were developed with the runtime approach in mind – at least at first.

Now, however, I notice a recent rise in interest in the compile-time approach. Where until now we only had runtime annotation libraries like Spring, Guice, Dozer we now have compile-time equivalents: immutables, MapStruct, Dagger 2 any many more for some specific use-cases.

One reason may be that Spring and Dozer, e.g., started out with the XML approach, wherein parsing the XML data and then doing something with it is quite similar to reading the annotations metadata and then doing virtually the same.

But are there some other reasons, maybe? Did developers only recently notice the advantages of ensuring the application correctness at compile-time? Or maybe Java 8 made the compile-time annotation processing / code-generation somewhat easier?

  • maybe the way I asked the question makes it sound too biased, but what I ask for is not really a discussion – rather the reason for sudden appearance of said compile-time libraries, which is a fact I actually gave examples for; or is it the question summary? I'll try to to improve it – Michal M Jun 25 '18 at 7:39
  • It may just be my impression, but I think that for something so closely attached to the actual usage of the class, it makes no sense to have a completely separate configuration file for it as you'd have to constantly check back and forth. It makes sense to have all the information you require to know how it works in one place. – Neil Jun 25 '18 at 8:49
  • 1
    Some "related" questions that were not considered "opinion based": - Are XML schemas bad... - Is it viable to... - Using a strong type system in the real world (...)? - Is it a good practice to suppress warnings in your code? - What is the best use of @Deprecated Java annotation (...)? How those are considered not primarily opinion-based while mine is, is truly beyond me. – Michal M Jun 25 '18 at 10:23
  • 1
    looking for stuff like any possible facts wouldn't be a good fit over here I'm afraid, see Why do 'some examples' and 'list of things' questions get closed? – gnat Jun 25 '18 at 11:45