Module Descriptor

module Descriptor: sig .. end
Definition and utility functions related to descriptor handling.


Java types definition

type java_type = [ `Array of non_void_java_type
| `Boolean
| `Byte
| `Char
| `Class of Name.for_class
| `Double
| `Float
| `Int
| `Long
| `Short
| `Void ]
Definition of Java types.
type non_void_java_type = [ `Array of non_void_java_type
| `Boolean
| `Byte
| `Char
| `Class of Name.for_class
| `Double
| `Float
| `Int
| `Long
| `Short ]
Definition of Java types.
type array_type = [ `Array of
[ `Array of 'a
| `Boolean
| `Byte
| `Char
| `Class of Name.for_class
| `Double
| `Float
| `Int
| `Long
| `Short ] as 'a ]
Definition of Java array types.

Exception

type error = 
| Invalid_class_name
| Invalid_array_element_type
| Array_with_too_many_dimensions
| Invalid_descriptor_string
| Empty_descriptor_string
| Invalid_field_type
| Invalid_local_variable_type
| Invalid_method_descriptor
| Invalid_method_parameter_type
| Void_not_allowed
exception Exception of error
val string_of_error : error -> string

Utility functions

val is_primitive : java_type -> bool
Tests whether the passed type is primitive.
val filter_void : error -> java_type -> non_void_java_type
filter_void err jt returns jt if it is not equal to `Void. Otherwise, Exception is raised with err as a parameter.
val filter_non_array : error -> java_type -> array_type
filter_non_array err jt returns jt if it is an array. Otherwise, Exception is raised with err as a parameter.
val java_type_of_internal_utf8 : Utils.UTF8.t -> java_type
Converts a string (as used in class file) into the corresponding Java type. Raises Exception if conversion fails.
val internal_utf8_of_java_type : java_type -> Utils.UTF8.t
Converts a Java type into the corresponding string (as used in class file). Raises Exception if conversion fails.
val external_utf8_of_java_type : java_type -> Utils.UTF8.t
Returns the textual representation of the passed Java type.
val java_type_of_external_utf8 : Utils.UTF8.t -> java_type
Returns the Java type corresponding to the passed string. Raises Exception if the string does not represent a Java type. Also Raises Exception if the type is invalid.
val equal_java_type : java_type -> java_type -> bool
val compare_java_type : java_type -> java_type -> int
val hash_java_type : java_type -> int

Field descriptors

type for_field = non_void_java_type 
Type for field descriptor.
val field_of_utf8 : Utils.UTF8.t -> for_field
Converts a string into the corresponding field descriptor. Raises Exception if conversion fails.
val utf8_of_field : for_field -> Utils.UTF8.t
Converts a field descriptor into the corresponding string. Raises Exception if conversion fails.
val java_type_of_external_utf8_no_void : Utils.UTF8.t -> for_field
Same as java_type_of_external_utf8 but raises Exception if the decoded type is equal to the Java type void.
val java_type_of_internal_utf8_no_void : Utils.UTF8.t -> for_field
Same as java_type_of_internal_utf8 but raises Exception if the decoded type is equal to the Java type void.
val equal_for_field : for_field -> for_field -> bool
val compare_for_field : for_field -> for_field -> int
val hash_for_field : for_field -> int

Method descriptors

type for_parameter = non_void_java_type 
Type for parameter descriptor, bare alias of for_field used for increased readability.
val parameter_of_utf8 : Utils.UTF8.t -> for_parameter
Alias for field_of_utf8, used for increased readability.
val utf8_of_parameter : for_parameter -> Utils.UTF8.t
Alias for utf8_of_field, used for increased readability.
val equal_for_parameter : for_parameter -> for_parameter -> bool
val compare_for_parameter : for_parameter -> for_parameter -> int
val hash_for_parameter : for_parameter -> int
Hash function over parameter descriptors.
type for_method = for_parameter list * java_type 
Type for method descriptor, first component is the list of formal parameters while second component is the return type.
val method_of_utf8 : Utils.UTF8.t -> for_method
Converts a string into the corresponding method descriptor. Raises Exception if conversion fails.
val utf8_of_method : for_method -> Utils.UTF8.t
Converts a method descriptor into the corresponding string. Raises Exception if conversion fails.
val equal_for_method : for_method -> for_method -> bool
val compare_for_method : for_method -> for_method -> int
Comparison over method descriptors.
val hash_for_method : for_method -> int
Hash function over method descriptors.