Annotation Type LazyInit


  • @IncompatibleModifiers(modifier=FINAL)
    @Retention(RUNTIME)
    @Target(FIELD)
    public @interface LazyInit
    Use this annotation on any static or field that will be initialized lazily, where races yield no semantic difference in the code (as, for example, is the case with String.hashCode()). Note that lazily initializing a non-volatile field is hard to do correctly, and one should rarely use this. It should also only be done by developers who clearly understand the potential issues, and then, always using the pattern as presented in the getData method of this sample code below:
    {@code
     private final String source;