Through this annotation it is possible to indicate the original parameter types of the target
object method.
The only use case in which this annotation is useful, is when an interface is used as a proxy
of another class methods. The interface can take all its input parameters in an asynchronous way.
In such case, the values specified in the annotation will indicate the type of the parameters
expected by the target method.
For example, a method taking two integers:
public int sum(int i1, int i2);
can be proxied by a method defined as:
@Inputs({int.class, int.class})
public InvocationChannel<Integer, Integer> sum();
The proxying method can also return the routine wrapping the target one, as:
@Inputs({int.class, int.class})
public Routine<Integer, Integer> sum();
In such case, it is up to the caller to invoke it in the proper mode.
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.
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.Inputs *;
}
Created by davide-maestroni on 05/22/2015.