Module JSignature

module JSignature: sig .. end

This module describe the signatures used with generics. It defines the data types used to represent information extracted from the Signature attribute defined in Java 5 (chapter 4.4.4).


Types used in type declarations of generic signatures

type typeVariable = 
| TypeVariable of string

This is the type used for type variables as P in Collection<P>.

type typeArgument = 
| ArgumentExtends of fieldTypeSignature (*

e.g. <?+Object>

*)
| ArgumentInherits of fieldTypeSignature (*

e.g. <?-Object>

*)
| ArgumentIs of fieldTypeSignature (*

e.g. <Object>

*)
| ArgumentIsAny (*

<*>

*)
type simpleClassTypeSignature = {
   scts_name : string;
   scts_type_arguments : typeArgument list;
}
type classTypeSignature = {
   cts_package : string list;
   cts_enclosing_classes : simpleClassTypeSignature list;
   cts_simple_class_type_signature : simpleClassTypeSignature;
}
type formalTypeParameter = {
   ftp_name : string;
   ftp_class_bound : fieldTypeSignature option;
   ftp_interface_bounds : fieldTypeSignature list;
}
type throwsSignature = 
| ThrowsClass of classTypeSignature
| ThrowsTypeVariable of typeVariable
type typeSignature = 
| GBasic of JBasics.java_basic_type
| GObject of fieldTypeSignature

typeSignature is used for method parameters and return values of generic methods.

Types of generic signatures

type classSignature = {
   cs_formal_type_parameters : formalTypeParameter list;
   cs_super_class : classTypeSignature;
   cs_super_interfaces : classTypeSignature list;
}
type fieldTypeSignature = 
| GClass of classTypeSignature
| GArray of typeSignature
| GVariable of typeVariable

This type is for references. Generic fields are of this type (it cannot be of a basic type as it would not be generic anymore) but method arguments or even generic parameters are also of this type.

type methodTypeSignature = {
   mts_formal_type_parameters : formalTypeParameter list;
   mts_type_signature : typeSignature list;
   mts_return_type : typeSignature option;
   mts_throws : throwsSignature list;
}