+ Include dependency graph for java_utils.h:
+ This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Return type for get_java_primitive_type_info.
More...
Return type for get_boxed_type_info_by_name.
More...
Returns true iff the argument represents a string type (CharSequence, StringBuilder, StringBuffer or String).
If primitive_type is a Java primitive type, return information about it, otherwise return null.
If type_name is a Java boxed type tag, return information about it, otherwise return null.
Returns true iff the argument is the symbol-table identifier of a Java primitive wrapper type (for example, java::java.lang.Byte)
Returns true iff the argument is the fully qualified name of a Java primitive wrapper type (for example, java.lang.Byte)
Returns the number of JVM local variables (slots) taken by a local variable that, when translated to goto, has type t.
Returns the the number of JVM local variables (slots) used by the JVM to pass, upon call, the arguments of a Java method whose type is t.
Attaches a source location to an expression and all of its subexpressions.
Resolves a user-friendly method name (like packagename.Class.method) into an internal name (like java::packagename.Class.method:()V) The input may also have a type descriptor suffix to resolve ambiguity.
Given a pointer type to a Java class and a type representing a more specific Java class, return a pointer type to the more specific class with the same structure as the original pointer type.
Dereference an expression and flag it for a null-pointer check.
Add the components in components_to_add to the class denoted by class symbol.
Finds the corresponding closing delimiter to the given opening delimiter.
Create a (mathematical) function application expression.
Strip java:: prefix from given identifier.
Strip the package name from a java type, for the type to be pretty printed (java::java.lang.Integer -> Integer).
Finds an inherited component (method or field), taking component visibility into account.
Check if a symbol is a well-known non-null global.
Gets the identifier of the class which declared a given symbol.
Sets the identifier of the class which declared a given symbol to declaring_class.
Get JVM type name of the class in which method_name is defined.
Methods belonging to the class org.cprover.CProver that should be ignored (not converted), leaving the driver program to stub them if it wishes.
Macro Definition Documentation
◆ JAVA_STRING_LITERAL_PREFIX
#
define JAVA_STRING_LITERAL_PREFIX "java::java.lang.String.Literal"
Function Documentation
◆ checked_dereference()
Dereference an expression and flag it for a null-pointer check.
- Parameters
-
expr expression to dereference and check
Definition at line 281 of file java_utils.cpp.
◆ class_name_from_method_name()
std::optional< std::string > class_name_from_method_name
(
const std::string &
method_name )
Get JVM type name of the class in which method_name is defined.
Returns an empty optional if the class name cannot be retrieved, e.g. method_name is an internal function.
Definition at line 580 of file java_utils.cpp.
◆ declaring_class()
Gets the identifier of the class which declared a given symbol.
If the symbol is not declared by a class then an empty optional is returned. This is used for method symbols and static field symbols to link them back to the class which declared them.
Definition at line 568 of file java_utils.cpp.
◆ find_closing_delimiter()
size_t find_closing_delimiter
(
const std::string &
src,
)
Finds the corresponding closing delimiter to the given opening delimiter.
It is assumed that open_pos points to the opening delimiter open_char in the src string. The depth of nesting is counted to identify the correct closing delimiter.
A typical use case is for example Java generic types, e.g., List<List<T>>
- Parameters
-
src the source string to scan
open_pos the initial position of the opening delimiter from where to start the search
open_char the opening delimiter
close_char the closing delimiter
- Returns
- the index of the matching corresponding closing delimiter in
src
Definition at line 302 of file java_utils.cpp.
◆ fresh_java_symbol()
const std::string &
basename_prefix,
)
- Parameters
-
type type of new symbol
basename_prefix new symbol will be named function_name::basename_prefix$num
source_location new symbol source loc
function_name name of the function in which the symbol is defined
symbol_table table to add the new symbol to
- Returns
- fresh-named symbol with the requested name pattern
Definition at line 555 of file java_utils.cpp.
◆ generate_class_stub()
◆ get_boxed_type_info_by_name()
If type_name is a Java boxed type tag, return information about it, otherwise return null.
Definition at line 36 of file java_utils.cpp.
◆ get_inherited_component()
Finds an inherited component (method or field), taking component visibility into account.
- Parameters
-
component_class_id class to start searching from. For example, if trying to resolve a reference to
A.b, component_class_id is "A".
component_name component basename to search for. If searching for
A.b, this is "b".
symbol_table global symbol table.
include_interfaces if true, search for the given component in all ancestors including interfaces, rather than just parents.
- Returns
- the concrete component referred to if any is found, or an invalid resolve_inherited_componentt::inherited_componentt otherwise.
Definition at line 448 of file java_utils.cpp.
◆ get_java_primitive_type_info()
If primitive_type is a Java primitive type, return information about it, otherwise return null.
Definition at line 63 of file java_utils.cpp.
◆ is_java_string_literal_id()
- Parameters
-
id any string
- Returns
- Returns true if 'id' identifies a string literal symbol
Definition at line 207 of file java_utils.cpp.
◆ is_java_string_type()
Returns true iff the argument represents a string type (CharSequence, StringBuilder, StringBuffer or String).
The check for the length and data components is necessary in the case where string refinement is not activated. In this case, struct_type only contains the standard Object fields (or may have some other model entirely), and in particular may not have length and data fields.
Definition at line 27 of file java_utils.cpp.
◆ is_non_null_library_global()
Check if a symbol is a well-known non-null global.
- Parameters
-
symbolid symbol id to check
- Returns
- true if this static field is known never to be null
Definition at line 519 of file java_utils.cpp.
◆ is_primitive_wrapper_type_id()
Returns true iff the argument is the symbol-table identifier of a Java primitive wrapper type (for example, java::java.lang.Byte)
Definition at line 109 of file java_utils.cpp.
◆ is_primitive_wrapper_type_name()
bool is_primitive_wrapper_type_name
(
const std::string &
type_name )
Returns true iff the argument is the fully qualified name of a Java primitive wrapper type (for example, java.lang.Byte)
Definition at line 114 of file java_utils.cpp.
◆ java_add_components_to_class()
void java_add_components_to_class
(
symbolt &
class_symbol,
)
Add the components in components_to_add to the class denoted by class symbol.
- Parameters
-
class_symbol The symbol representing the class we want to modify.
components_to_add The vector with the components we want to add.
Definition at line 341 of file java_utils.cpp.
◆ java_class_to_package()
const std::string java_class_to_package
(
const std::string &
canonical_classname )
◆ java_local_variable_slots()
Returns the number of JVM local variables (slots) taken by a local variable that, when translated to goto, has type t.
Definition at line 128 of file java_utils.cpp.
◆ java_method_parameter_slots()
Returns the the number of JVM local variables (slots) used by the JVM to pass, upon call, the arguments of a Java method whose type is t.
Definition at line 147 of file java_utils.cpp.
◆ make_function_application()
Create a (mathematical) function application expression.
The application has the type of the codomain (range) of the function.
- Parameters
-
function_name the name of the function
arguments a list of arguments (an element of the domain)
range return type (codomain) of the function
symbol_table a symbol table
- Returns
- a function application expression representing:
function_name(arguments)
Definition at line 384 of file java_utils.cpp.
◆ merge_source_location_rec()
void merge_source_location_rec
(
exprt &
expr,
)
Attaches a source location to an expression and all of its subexpressions.
Usually only codet needs this, but there are a few known examples of expressions needing a location, such as goto_convertt::do_function_call_symbol (function() needs a location) and goto_convertt::clean_expr (any subexpression being split into a separate instruction needs a location), so for safety we give every mentioned expression a location. Any code or expressions with source location fields already set keep those fields using rules of source_locationt::merge.
Definition at line 198 of file java_utils.cpp.
◆ pointer_to_replacement_type()
Given a pointer type to a Java class and a type representing a more specific Java class, return a pointer type to the more specific class with the same structure as the original pointer type.
Definition at line 269 of file java_utils.cpp.
◆ pretty_print_java_type()
std::string pretty_print_java_type
(
const std::string &
fqn_java_type )
Strip the package name from a java type, for the type to be pretty printed (java::java.lang.Integer -> Integer).
- Parameters
-
fqn_java_type The java type we want to pretty print.
- Returns
- The pretty printed type if there was a match of the qualifiers, or the type as it was passed otherwise.
Definition at line 421 of file java_utils.cpp.
◆ resolve_friendly_method_name()
irep_idt resolve_friendly_method_name
(
const std::string &
friendly_name,
std::string &
error
)
Resolves a user-friendly method name (like packagename.Class.method) into an internal name (like java::packagename.Class.method:()V) The input may also have a type descriptor suffix to resolve ambiguity.
On error, returns irep_idt() and sets error.
- Parameters
-
friendly_name user-friendly method name
symbol_table global symbol table
[out] error gets error description on failure
Definition at line 212 of file java_utils.cpp.
◆ set_declaring_class()
Sets the identifier of the class which declared a given symbol to declaring_class.
Definition at line 574 of file java_utils.cpp.
◆ strip_java_namespace_prefix()
Strip java:: prefix from given identifier.
- Parameters
-
to_strip identifier from which the prefix is stripped
- Returns
- the identifier without without java:: prefix
Definition at line 407 of file java_utils.cpp.
Variable Documentation
◆ cprover_methods_to_ignore
const std::unordered_set<std::string> cprover_methods_to_ignore
extern
Methods belonging to the class org.cprover.CProver that should be ignored (not converted), leaving the driver program to stub them if it wishes.
Definition at line 529 of file java_utils.cpp.