Friday, 27 June 2014

RetentionPolicy.SOURCE

RetentionPolicy.SOURCE: The marked annotation is retained only in the source level and is ignored by the compiler. i.e. these are discarded during the compilation. These annotations don't make any sense after the compilation, so they aren't written to the bytecode.

Things like @SuppressWarnings, @Override are annotations used by the compiler not needed at runtime. For those RetentionPolicy.SOURCE would make sense.

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.SOURCE)
@interface MyAnnotation1{
    String value();
}



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment