Through this annotation it is possible to indicate the fields accessed by the target object
method.
This annotation is used to decorate methods that are to be invoked in an asynchronous way.
Note that the piece of code inside such methods will be automatically protected so to avoid
concurrency issues. Though, other parts of the code inside the same class will be not.
In order to prevent unexpected behaviors, it is advisable to avoid using the same class fields
(unless immutable) in protected and non-protected code, or to call synchronous methods through
routines as well.
This annotation is meant to have a finer control on this kind of protection. Each method can be
associated to specific fields accessed by the implementation, so that, shared ones are
guaranteed to be handled in a thread safe way. By default, that is when this annotation is
missing, all fields are protected.
Note that methods sharing the same fields cannot be executed in parallel.
Finally, be aware that a method might need to be made accessible in order to be called. That
means that, in case a
SecurityManager is installed, a security exception might
be raised based on the specific policy implemented.
Remember also that, in order for the annotation to properly work at run time, you will need to
add the following rules to your Proguard file (if employing it for shrinking or obfuscation):
-keepattributes RuntimeVisibleAnnotations
-keepclassmembers class ** {
@com.github.dm.jrt.annotation.SharedFields *;
}
Created by davide-maestroni on 01/26/2015.