WeakOuter

  • @WeakOuter annotation signifies a weak relationship between an inner class and its outer class, primarily used for lambdas.

  • By assigning a lambda expression to a local variable annotated with @WeakOuter, the lambda gets a weak reference to the outer class.

  • This annotation is exclusively applicable to local variables, encouraging its use at the lambda declaration point.

  • @WeakOuter inherits methods from java.lang.annotation.Annotation including annotationType(), equals(), hashCode(), and toString().

public abstract @interface WeakOuter implements Annotation

Annotation that indicates an inner class has a weak relationship to its owning class.

Lambdas can be given a weak outer reference by declaring a local variable with this annotation and assigning the lambda expression directly to the local variable. WeakOuter is only allowed on local variables, not fields, to encourage the annotation to be used where the lambda is declared.

Inherited Method Summary