Retention policy of an annotaion
#Rentention #Policy #interviewQA #Java ► SUBSCRIBE & LIKE!! ► Important Information and code guide available bottom of the Description section ► Official Email Id: [email protected] ► Download the sample java microservice application : https://github.com/admindebu/Spring-D... ► Follow on Facebook: https://www.facebook.com/TechTalkDebu ► Follow on LinkedIn: https://www.linkedin.com/in/debu-paul ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ► Here is our amazing playlist for Core Java, Spring MVC/Boot, Git and Microservice ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Core Java :: https://www.youtube.com/watch?v=IR_h0... 2. Core Java Important Interview QA : https://www.youtube.com/watch?v=CFoxr... 3. Spring MVC & Spring Boot :: https://www.youtube.com/watch?v=f-Wk1... 4. Micro Services :: https://www.youtube.com/watch?v=pscya... 5. Git/GitHub :: https://www.youtube.com/watch?v=XHxBA... 6. AWS :: https://www.youtube.com/watch?v=81Y_2... 7. Spring Security & OAuth : https://www.youtube.com/watch?v=AvV8l... 8. Coding and Programming : https://www.youtube.com/watch?v=o2BP4... 9. Raspberry PI & Arduino : https://www.youtube.com/watch?v=uauMF... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Watch my "Most Watched Videos" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ► HTTPS & HTTPS protocol :: https://www.youtube.com/watch?v=BlnSS... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A retention policy determines at what point annotation should be discarded. Java defined 3 types of retention policies through java.lang.annotation.RetentionPolicy enumeration. It has SOURCE, CLASS and RUNTIME. Annotation with retention policy SOURCE will be retained only with source code, and discarded during compile time. Annotation with retention policy CLASS will be retained till compiling the code, and discarded during runtime. Annotation with retention policy RUNTIME will be available to the JVM through runtime. The retention policy will be specified by using java built-in annotation @Retention, and we have to pass the retention policy type. The default retention policy type is CLASS. import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) public @interface MySampleAnn { String name(); String desc(); } class MyAnnTest{ @MySampleAnn(name = "test1", desc = "testing annotations") public void myTestMethod(){ //method implementation } } Thanks & Regards, Debu Paul
#Rentention #Policy #interviewQA #Java ► SUBSCRIBE & LIKE!! ► Important Information and code guide available bottom of the Description section ► Official Email Id: [email protected] ► Download the sample java microservice application : https://github.com/admindebu/Spring-D... ► Follow on Facebook: https://www.facebook.com/TechTalkDebu ► Follow on LinkedIn: https://www.linkedin.com/in/debu-paul ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ► Here is our amazing playlist for Core Java, Spring MVC/Boot, Git and Microservice ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Core Java :: https://www.youtube.com/watch?v=IR_h0... 2. Core Java Important Interview QA : https://www.youtube.com/watch?v=CFoxr... 3. Spring MVC & Spring Boot :: https://www.youtube.com/watch?v=f-Wk1... 4. Micro Services :: https://www.youtube.com/watch?v=pscya... 5. Git/GitHub :: https://www.youtube.com/watch?v=XHxBA... 6. AWS :: https://www.youtube.com/watch?v=81Y_2... 7. Spring Security & OAuth : https://www.youtube.com/watch?v=AvV8l... 8. Coding and Programming : https://www.youtube.com/watch?v=o2BP4... 9. Raspberry PI & Arduino : https://www.youtube.com/watch?v=uauMF... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Watch my "Most Watched Videos" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ► HTTPS & HTTPS protocol :: https://www.youtube.com/watch?v=BlnSS... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A retention policy determines at what point annotation should be discarded. Java defined 3 types of retention policies through java.lang.annotation.RetentionPolicy enumeration. It has SOURCE, CLASS and RUNTIME. Annotation with retention policy SOURCE will be retained only with source code, and discarded during compile time. Annotation with retention policy CLASS will be retained till compiling the code, and discarded during runtime. Annotation with retention policy RUNTIME will be available to the JVM through runtime. The retention policy will be specified by using java built-in annotation @Retention, and we have to pass the retention policy type. The default retention policy type is CLASS. import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) public @interface MySampleAnn { String name(); String desc(); } class MyAnnTest{ @MySampleAnn(name = "test1", desc = "testing annotations") public void myTestMethod(){ //method implementation } } Thanks & Regards, Debu Paul