org.curjent.impl.agent
Class ResultInfo

java.lang.Object
  extended by org.curjent.impl.agent.ResultInfo

final class ResultInfo
extends Object

Information for bytecode generation of method results. For non-void method return types, a field is generated in each method's message for the method's result. This class contains bytecode information for transferring results to and from the message, including information specific to agent methods returning Future values. It also contains information on execution of the method, such as whether or not it runs synchronously. The execution model is intimately tied to method return types.

The JVM specifies that an interface method is uniquely identified by its name, parameters, and return type. A task method, in contrast, is uniquely identified by only its name and parameters. Consequently, all interface methods with same name and parameters map to exactly one task method that has a matching name and parameters. For this reason, as well as for agent methods returning Future results, this class provides information for the interface's return type, the task's return type, and the message field type for the result if any. Another consequence of this many-to-one relationship between interface and task methods is that there is exactly one ResultInfo instance for each unique interface method, but potentially multiple instances associated with each task method.

The following naming convention is used for this class's fields: field names prefixed with type provide information on the interface's method; field names prefixed with task provide information on the corresponding task's method; and field names prefixed with message provide information on the corresponding message and its field, if any, for the task method's result.

See Also:
ParamInfo, MethodInfo, TypeInfo

Field Summary
(package private)  BoxedInfo messageBoxed
          Primitive value boxing and unboxing information for the message field's type.
(package private)  boolean messageCall
          true if messageFuture is true and the interface method's return type is AgentCall.
(package private)  String messageDescriptor
          Message field type descriptor.
(package private)  boolean messageFuture
          true if the agent call is asynchronous and returns a future value.
(package private)  String messageInternal
          Message field internal name.
(package private)  boolean messageResult
          true if the task method's return type is not void.
(package private)  boolean messageSynchronous
          true if the agent call is synchronous.
(package private)  Class<?> messageType
          Message field type for holding the return value.
(package private)  boolean taskFuture
          true if the task method's return type is a subclass of Future.
(package private)  Method taskMethod
          The task's method.
(package private)  boolean taskResult
          true if the task method's return type is not void.
(package private)  int taskSize
          Stack size of the return value.
(package private)  boolean taskSynchronous
          true if the task method is annotated as Synchronous.
(package private)  Class<?> taskType
          Task method's return type.
(package private)  boolean typeCall
          true if the interface method's return type is AgentCall.
(package private)  boolean typeFuture
          true if the interface method's return type is Future or AgentCall.
(package private)  Method typeMethod
          The interface's method.
(package private)  Class<?> typeType
          Interface method's return type.
(package private)  boolean typeVoid
          true if the interface method's return type is void.
 
Constructor Summary
ResultInfo(Method typeMethod)
          Initializes the interface method's return type fields (i.e., the fields of this class whose names begin with type) with information from the given interface method.
 
Method Summary
(package private)  boolean isCompatibleType(ResultInfo other)
          Returns true if two interface methods' return types are compatible.
(package private)  boolean isSameType(ResultInfo other)
          Returns true if two interface method's return types are the same class.
(package private)  void setTaskResult(Method taskMethod)
          Initializes the task method's return type fields (i.e., the fields of this class whose names begin with task) with information from the given task method, and evaluates the interface and task method information to derive the message field information (i.e., the fields of this class whose names begin with message).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typeMethod

Method typeMethod
The interface's method.


typeType

Class<?> typeType
Interface method's return type.


typeVoid

boolean typeVoid
true if the interface method's return type is void.


typeFuture

boolean typeFuture
true if the interface method's return type is Future or AgentCall.


typeCall

boolean typeCall
true if the interface method's return type is AgentCall.


taskMethod

Method taskMethod
The task's method.


taskType

Class<?> taskType
Task method's return type.


taskResult

boolean taskResult
true if the task method's return type is not void.


taskFuture

boolean taskFuture
true if the task method's return type is a subclass of Future.


taskSynchronous

boolean taskSynchronous
true if the task method is annotated as Synchronous.


taskSize

int taskSize
Stack size of the return value. Either 0 for void, 2 for long or double, or 1 for all others.


messageFuture

boolean messageFuture
true if the agent call is asynchronous and returns a future value. This implies the interface method's return type is Future or AgentCall, and the task's method is not annotated with Synchronous. If the task's method is annotated with Synchronous, the agent call synchronously returns a Future or AgentCall object.


messageCall

boolean messageCall
true if messageFuture is true and the interface method's return type is AgentCall.


messageSynchronous

boolean messageSynchronous
true if the agent call is synchronous. Cannot be true if messageFuture is true. A synchronous call implies the task's method is annotated with Synchronous, or the interface method's return type is not void nor Future or AgentCall.


messageType

Class<?> messageType
Message field type for holding the return value. This is normally the same as the task method's return type. The one exception is the case where this is an asynchronous call with a future return value, and the task's return type is, or is a subclass of, Future. In this case, the return value saved in the message is the value returned from the task result's get() method. This value is always of type Object.class.


messageResult

boolean messageResult
true if the task method's return type is not void. Always the same as taskResult; duplicated here to make the bytecode generators easier to read.


messageInternal

String messageInternal
Message field internal name. The JVM internal name for the field's type, such as "java/lang/String" for String.


messageDescriptor

String messageDescriptor
Message field type descriptor. The JVM descriptor for the field's type, such as "Ljava/lang/String;" for String.


messageBoxed

BoxedInfo messageBoxed
Primitive value boxing and unboxing information for the message field's type. null for non-primitive types.

Constructor Detail

ResultInfo

ResultInfo(Method typeMethod)
Initializes the interface method's return type fields (i.e., the fields of this class whose names begin with type) with information from the given interface method.

Method Detail

setTaskResult

void setTaskResult(Method taskMethod)
Initializes the task method's return type fields (i.e., the fields of this class whose names begin with task) with information from the given task method, and evaluates the interface and task method information to derive the message field information (i.e., the fields of this class whose names begin with message).

Throws:
AgentException - Task return type is not assignment compatible with its interface return type. Does not apply to asynchronous calls with future results.

isSameType

boolean isSameType(ResultInfo other)
Returns true if two interface method's return types are the same class.


isCompatibleType

boolean isCompatibleType(ResultInfo other)
Returns true if two interface methods' return types are compatible. The return types are compatible if either is assignment compatible with the other (which implies that both are at least potentially assignment compatible with the task method's return type).



Copyright 2009-2011 Tom Landon
Apache License 2.0