I'm new to Java and I'm a php developer. I can't understand Java annotations well. in php when I'm using a framework and I use some functions and libraries, when I don't understand something, using ctrl+click I can go inside that file and take a look and read the source code. but about Java annotations, I know what they are and how to use them. for example in spring boot for defining routes we use annotations e.x. @GetMapping("/api/v1/users") I want to know who (which class or snippet) is using value of this annotation. How can I see that code ? consider I want to write an annotation myself and I want to use it. how should I use my custom defined annotations? as I know most annotations are available just at compile time and not at runtime, so how should tell the compiler how should it take actions upon my annotations ?
Asked
Active
Viewed 26 times
0
-
1*"as I know most annotations are available just at compile time and not at runtime"*, that is completely untrue. You already gave the example of spring's `GetMapping`, that is a runtime annotation, as are most (or all) of spring's annotations. Google "java annotation processing". – luk2302 Mar 23 '20 at 16:17
-
The code to implement that would be in the Spring framework somewhere. Sorry I don't know where. You might have to ask on the Spring mailing list where that stuff is. However, most Java web frameworks are old, have a super huge amount of code, much of that code is legacy, and there's multiple layers of cruft and kludges because that's normal for 15 or 20 years of code maintenance, and it's not going to be easy to read and understand what is going on. – markspace Mar 23 '20 at 16:18