Module Lookup

module Lookup: sig .. end
Function allowing to search for classes, fields, constructors, and methods using UTF8 queries.


Base types and utility functions

type error = 
| Invalid_class_query of Utils.UTF8.t
| Cannot_find_class of Utils.UTF8.t
| Generic_arity_mismatch of Utils.UTF8.t * int * int
| Generic_cannot_be_parametrized
| Primitive_cannot_be_generic_argument
| Wildcard_cannot_be_generic_argument
| Generic_variable_bound_to_different_values of Utils.UTF8.t
| Void_cannot_be_an_array_element_type
| Invalid_generic_bound
| Ambiguity_in_generic_bound
| No_class_match
| Several_class_matches of Name.for_class list
| Invalid_field_query of Utils.UTF8.t
| No_field_match
| Several_field_matches of (Name.for_class * Name.for_field) list
| Invalid_constructor_query of Utils.UTF8.t
| No_constructor_match
| Several_constructor_matches of (Name.for_class * Descriptor.for_parameter list) list
| Invalid_regular_method_query of Utils.UTF8.t
| No_regular_method_match
| Several_regular_method_matches of (Name.for_class * Name.for_method * Descriptor.for_method) list
exception Exception of error
val string_of_error : error -> string
type java_type = [ `Array of non_void_java_type
| `Boolean
| `Byte
| `Char
| `Class of ClassDefinition.t
| `Double
| `Float
| `Generic of Utils.UTF8.t
| `Int
| `Long
| `Short
| `Void
| `Wildcard ]
Definition of Java types, akin to Descriptor.java_type but with extra cases:
type non_void_java_type = [ `Array of non_void_java_type
| `Boolean
| `Byte
| `Char
| `Class of ClassDefinition.t
| `Double
| `Float
| `Generic of Utils.UTF8.t
| `Int
| `Long
| `Short
| `Wildcard ]
Definition of Java types, akin to Descriptor.non_void_java_type but with extra cases:
type substitution = java_type Utils.UTF8Map.t 
The type of substitutions, mapping identifier of formal generic type parameters to their effective type.
type 'a result = {
   value :'a; (*The actual result of the query.*)
   with_generics :bool; (*Whether the query was generic-aware.*)
   substitution :substitution; (*The substitution of generic type parameters.*)
}
The type of query results.
val equal_java_type : java_type -> java_type -> bool
Equality over Java types.
val matches_descriptor : substitution -> java_type -> Descriptor.java_type -> bool
Tests whether a Java type matches a given Java type descriptor. The passed substitution is used to replace generic type variables.

Support for classes

type for_class 
The type of queries about classes.
val utf8_for_class : for_class -> Utils.UTF8.t
Returns the string representation of the passed query.
val make_for_class_from_utf8 : bool -> Utils.UTF8.t -> for_class
make_for_class_from_utf8 generics s returns a query looking for classes according to string s, generics indicating whether generic information should be used. A query should be a class name (possibly unqualified), possibly followed by generic parameters between angle brackets (if generics is true).

Raises Exception if s is not well-formed.

val search_for_classes : ?open_packages:Utils.UTF8.t list ->
ClassLoader.t -> for_class -> ClassDefinition.t result list
search_for_classes ~open_packages:op cl q returns a list of classes matching query q found in class loader cl, op giving the list of package prefixes that need not to appear (thus allowing to use short rather than fully-qualified class names).

Query examples:

The returned substitutions are: Some examples, based on the java.util.List<E> class:
val search_for_class : ?open_packages:Utils.UTF8.t list ->
ClassLoader.t -> for_class -> ClassDefinition.t result
Akin to search_for_classes, except that Exception is raised if the returned list contains zero or more than one class.
val for_classes : bool ->
?open_packages:Utils.UTF8.t list ->
ClassLoader.t -> Utils.UTF8.t -> ClassDefinition.t result list
for_classes generics ~open_packages:op cl s is a bare shorthand for search_for_classes ~open_packages:op cl (make_for_class_from_utf8 generics s).
val for_class : bool ->
?open_packages:Utils.UTF8.t list ->
ClassLoader.t -> Utils.UTF8.t -> ClassDefinition.t result
for_class generics ~open_packages:op cl s is a bare shorthand for search_for_class ~open_packages:op cl (make_for_class_from_utf8 generics s).

Support for fields

type for_field 
The type of queries about fields.
val utf8_for_field : for_field -> Utils.UTF8.t
Returns the string representation of the passed query.
val make_for_field_from_utf8 : bool -> Utils.UTF8.t -> for_field
make_for_field_from_utf8 generics s returns a query looking for fields according to string s, generics indicating whether generic information should be used. A query should successively contain: Raises Exception if s is not well-formed.
val search_for_fields : ?open_packages:Utils.UTF8.t list ->
ClassLoader.t ->
for_field -> (ClassDefinition.t * Field.t) result list
search_for_fields ~open_packages:op cl q returns a list of class/field couples matching query q found in class loader cl, op giving the list of package prefixes that need not to appear (thus allowing to use short rather than fully-qualified class names).

Query examples:


val search_for_field : ?open_packages:Utils.UTF8.t list ->
ClassLoader.t ->
for_field -> (ClassDefinition.t * Field.t) result
Akin to search_for_fields, except that Exception is raised if the returned list contains zero or more than one field.
val for_fields : bool ->
?open_packages:Utils.UTF8.t list ->
ClassLoader.t ->
Utils.UTF8.t -> (ClassDefinition.t * Field.t) result list
for_fields generics ~open_packages:op cl s is a bare shorthand for search_for_fields ~open_packages:op cl (make_for_field_from_utf8 generics s).
val for_field : bool ->
?open_packages:Utils.UTF8.t list ->
ClassLoader.t -> Utils.UTF8.t -> (ClassDefinition.t * Field.t) result
for_field generics ~open_packages:op cl s is a bare shorthand for search_for_field ~open_packages:op cl (make_for_field_from_utf8 generics s).

Support for constructors

type for_constructor 
The type of queries about constructors.
val utf8_for_constructor : for_constructor -> Utils.UTF8.t
Returns the string representation of the passed query.
val make_for_constructor_from_utf8 : bool -> Utils.UTF8.t -> for_constructor
make_for_constructor_from_utf8 generics s returns a query looking for constructors according to string s, generics indicating whether generic information should be used. A query should successively contain: Raises Exception if s is not well-formed.
val search_for_constructors : ?open_packages:Utils.UTF8.t list ->
ClassLoader.t ->
for_constructor ->
(ClassDefinition.t * Method.constructor) result list
search_for_constructors ~open_packages:op cl q returns a list of class/constructor couples matching query q found in class loader cl, op giving the list of package prefixes that need not to appear (thus allowing to use short rather than fully-qualified class names).

Query examples:


val search_for_constructor : ?open_packages:Utils.UTF8.t list ->
ClassLoader.t ->
for_constructor ->
(ClassDefinition.t * Method.constructor) result
Akin to search_for_constructors, except that Exception is raised if the returned list contains zero or more than one constructor.
val for_constructors : bool ->
?open_packages:Utils.UTF8.t list ->
ClassLoader.t ->
Utils.UTF8.t -> (ClassDefinition.t * Method.constructor) result list
for_constructors generics ~open_packages:op cl s is a bare shorthand for search_for_constructors ~open_packages:op cl (make_for_constructor_from_utf8 generics s).
val for_constructor : bool ->
?open_packages:Utils.UTF8.t list ->
ClassLoader.t ->
Utils.UTF8.t -> (ClassDefinition.t * Method.constructor) result
for_constructor generics ~open_packages:op cl s is a bare shorthand for search_for_constructor ~open_packages:op cl (make_for_constructor_from_utf8 generics s).

Support for regular methods

type for_regular_method 
The type of queries about regular methods.
val utf8_for_regular_method : for_regular_method -> Utils.UTF8.t
Returns the string representation of the passed query.
val make_for_regular_method_from_utf8 : bool -> Utils.UTF8.t -> for_regular_method
make_for_regular_method_from_utf8 generics s returns a query looking for regular methods according to string s, generics indicating whether generic information should be used. A query should successively contain: Raises Exception if s is not well-formed.
val search_for_regular_methods : ?open_packages:Utils.UTF8.t list ->
ClassLoader.t ->
for_regular_method ->
(ClassDefinition.t * Method.regular) result list
search_for_regular_methods ~open_packages:op cl q returns a list of class/method couples matching query q found in class loader cl, op giving the list of package prefixes that need not to appear (thus allowing to use short rather than fully-qualified class names).

Query examples:


val search_for_regular_method : ?open_packages:Utils.UTF8.t list ->
ClassLoader.t ->
for_regular_method ->
(ClassDefinition.t * Method.regular) result
Akin to search_for_regular_methods, except that Exception is raised if the returned list contains zero or more than one regular method.
val for_regular_methods : bool ->
?open_packages:Utils.UTF8.t list ->
ClassLoader.t ->
Utils.UTF8.t -> (ClassDefinition.t * Method.regular) result list
for_regular_methods generics ~open_packages:op cl s is a bare shorthand for search_for_regular_methods ~open_packages:op cl (make_for_regular_method_from_utf8 generics s).
val for_regular_method : bool ->
?open_packages:Utils.UTF8.t list ->
ClassLoader.t ->
Utils.UTF8.t -> (ClassDefinition.t * Method.regular) result
for_regular_method generics ~open_packages:op cl s is a bare shorthand for search_for_regular_method ~open_packages:op cl (make_for_regular_method_from_utf8 generics s).