Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This annotation is used to mark fields, local variables, parameters and types as potential off-heap references that require retain() and release() to manage their lifecycle.  When marking a type, such as EntryEventImpl, this annotation indicates that the type manages one or more off-heap references as part of its lifecycle.

3.1 Targets

  • Field (instance variable)

  • Local Variable

  • Parameter

  • Type (class or interface declaration)

3.2 Retention

  • Source

3.3 Members

  • value - Type is OffHeapIdentifier[].  Optional.  Used to match this @Offheap with one or more additional off-heap annotations.

3.4 Examples

1. @Offheap on a field with multiple identifiers

...

  1. When used on a method declaration it indicates that the method called retain on the return value if it is an off-heap reference.
  2. When used on a constructor declaration this annotation indicates that field members may be off-heap references and retain will be invoked on the field methods.  This also indicates that the class will have a release method.
  3. When used on a parameter declaration it indicates that the method will call retain on the parameter if it is an off-heap reference.

4.1 Targets

  • Parameter

  • Method

  • Constructor

4.2 Retention

  • Source

4.3 Members

  • value - Type is OffHeapIdentifier[].  Optional.  Used to match this @Retained with one or more off-heap annotations.

4.4 Examples

4.4.1 @Retained on a method parameter

...

will call release on the parameter if it is an off-heap reference.  When used on method declarations this annotation indicates that the method will call release on one or more field members of the class instance.

5.1 Targets

  • Method

  • Parameter

5.2 Retention

  • Source

5.3 Members

  • value - Type is OffHeapIdentifier[].  Optional.  Used to match this @Released with one or more off-heap annotations.

5.4 Examples

1. @Released on a method parameter

...

This annotation is used on methods to indicate that the return value may be an off-heap reference that the caller is responsible for calling retain on.

6.1 Targets

  • Method

6.2 Retention

  • Source

6.3 Members

  • value - Type is OffHeapIdentifier[].  Optional.  Used to match this @Unretained with one or more off-heap annotations.

6.4 Examples

1. @Unretained

...

The following matrix summarizes which off-heap annotations are legal for each Java target:

 

Annotation

Local Variable

Field

Method

Parameter

Constructor

@Offheap

yes

yes

no

yes

no

@Released

no

no

yes

yes

no

@Retained

no

no

yes

yes

yes

@Unretained

no

no

yes

no

no