37 bool parse()
override;
71 log.
error() <<
"invalid constant pool index (" << index <<
")"
108 void rbytecode(std::vector<instructiont> &);
114 std::optional<lambda_method_handlet>
120 for(std::size_t i=0; i<bytes; i++)
131 template <
typename T>
135 std::is_unsigned<T>::value,
"T should be an unsigned integer");
136 const constexpr
size_t bytes =
sizeof(T);
138 for(
size_t i = 0; i < bytes; i++)
146 result |=
static_cast<u1>(
in->get());
148 return narrow_cast<T>(result);
154 #define CONSTANT_Class 7
155 #define CONSTANT_Fieldref 9
156 #define CONSTANT_Methodref 10
157 #define CONSTANT_InterfaceMethodref 11
158 #define CONSTANT_String 8
159 #define CONSTANT_Integer 3
160 #define CONSTANT_Float 4
161 #define CONSTANT_Long 5
162 #define CONSTANT_Double 6
163 #define CONSTANT_NameAndType 12
164 #define CONSTANT_Utf8 1
165 #define CONSTANT_MethodHandle 15
166 #define CONSTANT_MethodType 16
167 #define CONSTANT_InvokeDynamic 18
169 #define VTYPE_INFO_TOP 0
170 #define VTYPE_INFO_INTEGER 1
171 #define VTYPE_INFO_FLOAT 2
172 #define VTYPE_INFO_LONG 3
173 #define VTYPE_INFO_DOUBLE 4
174 #define VTYPE_INFO_ITEM_NULL 5
175 #define VTYPE_INFO_UNINIT_THIS 6
176 #define VTYPE_INFO_OBJECT 7
177 #define VTYPE_INFO_UNINIT 8
286 "name_and_typeindex did not correspond to a name_and_type in the "
389 catch(
const char *message)
395 catch(
const std::string &message)
410 #define ACC_PUBLIC 0x0001u
411 #define ACC_PRIVATE 0x0002u
412 #define ACC_PROTECTED 0x0004u
413 #define ACC_STATIC 0x0008u
414 #define ACC_FINAL 0x0010u
415 #define ACC_SYNCHRONIZED 0x0020u
416 #define ACC_BRIDGE 0x0040u
417 #define ACC_NATIVE 0x0100u
418 #define ACC_INTERFACE 0x0200u
419 #define ACC_ABSTRACT 0x0400u
420 #define ACC_STRICT 0x0800u
421 #define ACC_SYNTHETIC 0x1000u
422 #define ACC_ANNOTATION 0x2000u
423 #define ACC_ENUM 0x4000u
425 #define UNUSED_u2(x) \
427 const u2 x = read<u2>(); \
436 const u4 magic = read<u4>();
438 const u2 major_version = read<u2>();
440 if(magic!=0xCAFEBABE)
456 const u2 access_flags = read<u2>();
457 const u2 this_class = read<u2>();
458 const u2 super_class = read<u2>();
485 const u2 attributes_count = read<u2>();
487 for(std::size_t j=0; j<attributes_count; j++)
521 if(field.signature.has_value())
543 for(
const auto ¶meter_annotations : method.parameter_annotations)
546 if(method.signature.has_value())
561 for(
const auto &var : method.local_variable_table)
563 if(var.signature.has_value())
583 if(src.
id()==ID_code)
591 else if(src.
id() == ID_struct_tag)
599 else if(src.
id()==ID_struct)
605 else if(src.
id()==ID_pointer)
612 const std::vector<annotationt> &annotations)
614 for(
const auto &annotation : annotations)
617 for(
const auto &element_value_pair : annotation.element_value_pairs)
627 if(
const auto &symbol_expr = expr_try_dynamic_cast<symbol_exprt>(value))
629 const irep_idt &value_id = symbol_expr->get_identifier();
632 else if(
const auto &array_expr = expr_try_dynamic_cast<array_exprt>(value))
645 const u2 constant_pool_count = read<u2>();
646 if(constant_pool_count==0)
657 it->tag = read<u1>();
662 it->ref1 = read<u2>();
670 it->ref1 = read<u2>();
671 it->ref2 = read<u2>();
676 it->ref1 = read<u2>();
681 it->number = read<u4>();
686 it->number = read<u8>();
699 const u2 bytes = read<u2>();
709 it->ref1 = read<u1>();
710 it->ref2 = read<u2>();
714 log.
error() <<
"unknown constant pool entry (" << it->tag <<
")"
724 [&](constant_poolt::value_type &entry) {
729 const std::string &s = id2string(pool_entry(entry.ref1).s);
730 entry.expr = type_exprt(java_classname(s));
734 case CONSTANT_Fieldref:
736 const pool_entryt &nameandtype_entry = pool_entry(entry.ref2);
737 const pool_entryt &name_entry=pool_entry(nameandtype_entry.ref1);
738 const pool_entryt &class_entry = pool_entry(entry.ref1);
739 const pool_entryt &class_name_entry=pool_entry(class_entry.ref1);
740 typet type=type_entry(nameandtype_entry.ref2);
742 auto class_tag = java_classname(id2string(class_name_entry.s));
744 fieldref_exprt fieldref(type, name_entry.s, class_tag.get_identifier());
746 entry.expr = fieldref;
750 case CONSTANT_Methodref:
751 case CONSTANT_InterfaceMethodref:
753 const pool_entryt &nameandtype_entry = pool_entry(entry.ref2);
754 const pool_entryt &name_entry=pool_entry(nameandtype_entry.ref1);
755 const pool_entryt &class_entry = pool_entry(entry.ref1);
756 const pool_entryt &class_name_entry=pool_entry(class_entry.ref1);
757 typet type=type_entry(nameandtype_entry.ref2);
759 auto class_tag = java_classname(id2string(class_name_entry.s));
761 irep_idt mangled_method_name =
762 id2string(name_entry.s) +
":" +
763 id2string(pool_entry(nameandtype_entry.ref2).s);
765 irep_idt class_id = class_tag.get_identifier();
767 entry.expr = class_method_descriptor_exprt{
768 type, mangled_method_name, class_id, name_entry.s};
772 case CONSTANT_String:
775 entry.expr = java_string_literal_exprt{pool_entry(entry.ref1).s};
779 case CONSTANT_Integer:
780 entry.expr = from_integer(entry.number, java_int_type());
785 ieee_floatt value(ieee_float_spect::single_precision());
786 value.unpack(entry.number);
787 entry.expr = value.to_expr();
792 entry.expr = from_integer(entry.number, java_long_type());
795 case CONSTANT_Double:
797 ieee_floatt value(ieee_float_spect::double_precision());
798 value.unpack(entry.number);
799 entry.expr = value.to_expr();
803 case CONSTANT_NameAndType:
805 entry.expr.id(
"nameandtype");
809 case CONSTANT_MethodHandle:
811 entry.expr.id(
"methodhandle");
815 case CONSTANT_MethodType:
817 entry.expr.id(
"methodtype");
821 case CONSTANT_InvokeDynamic:
823 entry.expr.id(
"invokedynamic");
824 const pool_entryt &nameandtype_entry = pool_entry(entry.ref2);
825 typet type=type_entry(nameandtype_entry.ref2);
826 type.set(ID_java_lambda_method_handle_index, entry.ref1);
827 entry.expr.type() = type;
836 const u2 interfaces_count = read<u2>();
838 for(std::size_t i=0; i<interfaces_count; i++)
840 constant(read<u2>()).type().get(ID_C_base_name));
845 const u2 fields_count = read<u2>();
847 for(std::size_t i=0; i<fields_count; i++)
851 const u2 access_flags = read<u2>();
852 const u2 name_index = read<u2>();
853 const u2 descriptor_index = read<u2>();
854 const u2 attributes_count = read<u2>();
865 const auto flags = (field.
is_public ? 1 : 0) +
868 DATA_INVARIANT(flags<=1,
"at most one of public, protected, private");
870 for(std::size_t j=0; j<attributes_count; j++)
886 const u4 code_length = read<u4>();
889 size_t bytecode_index=0;
891 for(address=0; address<code_length; address++)
893 bool wide_instruction=
false;
894 u4 start_of_instruction=address;
896 u1 bytecode = read<u1>();
900 wide_instruction=
true;
902 bytecode = read<u1>();
909 std::string(
"Unexpected wide instruction: ") +
913 instructions.emplace_back();
916 instruction.
address=start_of_instruction;
945 const s1 c = read<u1>();
953 const s2 offset = read<u2>();
956 instruction.
args.push_back(
964 const s4 offset = read<u4>();
967 instruction.
args.push_back(
977 const u2 v = read<u2>();
983 const u1 v = read<u1>();
995 const u2 v = read<u2>();
997 const s2 c = read<u2>();
1003 const u1 v = read<u1>();
1005 const s1 c = read<u1>();
1013 const u2 c = read<u2>();
1015 const u1 b1 = read<u1>();
1017 const u1 b2 = read<u1>();
1025 u4 base_offset=address;
1028 while(((address + 1u) & 3u) != 0)
1035 const s4 default_value = read<u4>();
1038 instruction.
args.push_back(
1043 const u4 npairs = read<u4>();
1046 for(std::size_t i=0; i<npairs; i++)
1048 const s4 match = read<u4>();
1049 const s4 offset = read<u4>();
1050 instruction.
args.push_back(
1054 instruction.
args.push_back(
1063 size_t base_offset=address;
1066 while(((address + 1u) & 3u) != 0)
1073 const s4 default_value = read<u4>();
1074 instruction.
args.push_back(
1079 const s4 low_value = read<u4>();
1083 const s4 high_value = read<u4>();
1087 for(
s4 i=low_value; i<=high_value; i++)
1089 s4 offset = read<u4>();
1093 instruction.
args.push_back(
1102 const u2 c = read<u2>();
1104 const u1 dimensions = read<u1>();
1105 instruction.
args.push_back(
1122 case T_INT: t.
id(ID_int);
break;
1133 const s2 s = read<u2>();
1140 throw "unknown JVM bytecode instruction";
1145 if(address!=code_length)
1154 const u2 attribute_name_index = read<u2>();
1155 const u4 attribute_length = read<u4>();
1159 if(attribute_name ==
"Code")
1169 const u2 exception_table_length = read<u2>();
1176 for(std::size_t e = 0; e < exception_table_length; e++)
1178 const u2 start_pc = read<u2>();
1179 const u2 end_pc = read<u2>();
1185 "The start_pc must be less than the end_pc as this is the range the "
1186 "exception is active");
1188 const u2 handler_pc = read<u2>();
1189 const u2 catch_type = read<u2>();
1199 u2 attributes_count = read<u2>();
1201 for(std::size_t j=0; j<attributes_count; j++)
1214 if(!instruction.source_location.get_line().empty())
1215 line_number = instruction.source_location.get_line();
1216 else if(!line_number.
empty())
1217 instruction.source_location.set_line(line_number);
1218 instruction.source_location.set_function(
1223 const auto it = std::find_if(
1227 return !instruction.source_location.get_line().empty();
1232 else if(attribute_name==
"Signature")
1234 const u2 signature_index = read<u2>();
1237 else if(attribute_name==
"RuntimeInvisibleAnnotations" ||
1238 attribute_name==
"RuntimeVisibleAnnotations")
1243 attribute_name ==
"RuntimeInvisibleParameterAnnotations" ||
1244 attribute_name ==
"RuntimeVisibleParameterAnnotations")
1246 const u1 parameter_count = read<u1>();
1254 for(
u2 param_no = 0; param_no < parameter_count; ++param_no)
1257 else if(attribute_name ==
"Exceptions")
1267 const u2 attribute_name_index = read<u2>();
1268 const u4 attribute_length = read<u4>();
1272 if(attribute_name==
"Signature")
1274 const u2 signature_index = read<u2>();
1277 else if(attribute_name==
"RuntimeInvisibleAnnotations" ||
1278 attribute_name==
"RuntimeVisibleAnnotations")
1288 const u2 attribute_name_index = read<u2>();
1289 const u4 attribute_length = read<u4>();
1293 if(attribute_name==
"LineNumberTable")
1295 std::map<unsigned, std::reference_wrapper<instructiont>> instruction_map;
1297 instruction_map.emplace(instruction.address, instruction);
1299 const u2 line_number_table_length = read<u2>();
1301 for(std::size_t i=0; i<line_number_table_length; i++)
1303 const u2 start_pc = read<u2>();
1304 const u2 line_number = read<u2>();
1307 auto it = instruction_map.find(start_pc);
1309 if(it!=instruction_map.end())
1310 it->second.get().source_location.set_line(line_number);
1313 else if(attribute_name==
"LocalVariableTable")
1315 const u2 local_variable_table_length = read<u2>();
1319 for(std::size_t i=0; i<local_variable_table_length; i++)
1321 const u2 start_pc = read<u2>();
1322 const u2 length = read<u2>();
1323 const u2 name_index = read<u2>();
1324 const u2 descriptor_index = read<u2>();
1325 const u2 index = read<u2>();
1335 else if(attribute_name==
"LocalVariableTypeTable")
1339 else if(attribute_name==
"StackMapTable")
1341 const u2 stack_map_entries = read<u2>();
1345 for(
size_t i=0; i<stack_map_entries; i++)
1347 const u1 frame_type = read<u1>();
1354 else if(64<=frame_type && frame_type<=127)
1364 else if(frame_type==247)
1371 const u2 offset_delta = read<u2>();
1376 else if(248<=frame_type && frame_type<=250)
1381 const u2 offset_delta = read<u2>();
1384 else if(frame_type==251)
1390 const u2 offset_delta = read<u2>();
1393 else if(252<=frame_type && frame_type<=254)
1395 size_t new_locals = frame_type - 251;
1399 const u2 offset_delta = read<u2>();
1401 for(
size_t k=0; k<new_locals; k++)
1410 else if(frame_type==255)
1413 const u2 offset_delta = read<u2>();
1415 const u2 number_locals = read<u2>();
1417 for(
size_t k=0; k<(size_t) number_locals; k++)
1425 const u2 number_stack_items = read<u2>();
1427 for(
size_t k=0; k<(size_t) number_stack_items; k++)
1437 throw "error: unknown stack frame type encountered";
1447 const u1 tag = read<u1>();
1480 throw "error: unknown verification type info encountered";
1485 std::vector<annotationt> &annotations)
1487 const u2 num_annotations = read<u2>();
1489 for(
u2 number=0; number<num_annotations; number++)
1493 annotations.push_back(annotation);
1500 const u2 type_index = read<u2>();
1508 const u2 num_element_value_pairs = read<u2>();
1509 element_value_pairs.resize(num_element_value_pairs);
1511 for(
auto &element_value_pair : element_value_pairs)
1513 const u2 element_name_index = read<u2>();
1514 element_value_pair.element_name=
pool_entry(element_name_index).
s;
1527 const u1 tag = read<u1>();
1541 const u2 class_info_index = read<u2>();
1556 const u2 num_values = read<u2>();
1558 values.reserve(num_values);
1559 for(std::size_t i=0; i<num_values; i++)
1568 const u2 const_value_index = read<u2>();
1574 const u2 const_value_index = read<u2>();
1575 return constant(const_value_index);
1592 const u4 &attribute_length)
1595 std::string name = parsed_class.
name.
c_str();
1596 const u2 number_of_classes = read<u2>();
1597 const u4 number_of_bytes_to_be_read = number_of_classes * 8 + 2;
1599 number_of_bytes_to_be_read == attribute_length,
1600 "The number of bytes to be read for the InnerClasses attribute does not "
1601 "match the attribute length.");
1603 const auto pool_entry_lambda = [
this](
u2 index) ->
pool_entryt & {
1606 const auto remove_separator_char = [](std::string str,
char ch) {
1607 str.erase(std::remove(str.begin(), str.end(), ch), str.end());
1611 for(
int i = 0; i < number_of_classes; i++)
1613 const u2 inner_class_info_index = read<u2>();
1614 const u2 outer_class_info_index = read<u2>();
1615 const u2 inner_name_index = read<u2>();
1616 const u2 inner_class_access_flags = read<u2>();
1618 std::string inner_class_info_name =
1621 bool is_private = (inner_class_access_flags &
ACC_PRIVATE) != 0;
1622 bool is_public = (inner_class_access_flags &
ACC_PUBLIC) != 0;
1623 bool is_protected = (inner_class_access_flags &
ACC_PROTECTED) != 0;
1624 bool is_static = (inner_class_access_flags &
ACC_STATIC) != 0;
1629 bool is_inner_class = remove_separator_char(
id2string(parsed_class.
name),
'.') ==
1630 remove_separator_char(inner_class_info_name,
'/');
1636 if(inner_name_index == 0)
1639 parsed_class.
inner_name = pool_entry_lambda(inner_name_index).s;
1642 if(outer_class_info_index == 0)
1650 std::string outer_class_info_name =
1669 const u2 number_of_exceptions = read<u2>();
1671 std::vector<irep_idt> exceptions;
1672 for(
size_t i = 0; i < number_of_exceptions; i++)
1674 const u2 exception_index_table = read<u2>();
1677 exceptions.push_back(exception_name);
1686 const u2 attribute_name_index = read<u2>();
1687 const u4 attribute_length = read<u4>();
1691 if(attribute_name==
"SourceFile")
1693 const u2 sourcefile_index = read<u2>();
1697 size_t last_index = fqn.find_last_of(
'.');
1698 if(last_index==std::string::npos)
1702 std::string package_name=fqn.substr(0, last_index+1);
1703 std::replace(package_name.begin(), package_name.end(),
'.',
'/');
1704 const std::string &full_file_name=
1706 sourcefile_name=full_file_name;
1709 for(
auto &method : parsed_class.
methods)
1711 method.source_location.set_file(sourcefile_name);
1712 for(
auto &instruction : method.instructions)
1714 if(!instruction.source_location.get_line().empty())
1715 instruction.source_location.set_file(sourcefile_name);
1719 else if(attribute_name==
"Signature")
1721 const u2 signature_index = read<u2>();
1727 else if(attribute_name==
"RuntimeInvisibleAnnotations" ||
1728 attribute_name==
"RuntimeVisibleAnnotations")
1732 else if(attribute_name ==
"BootstrapMethods")
1738 "only one BootstrapMethods argument is allowed in a class file");
1744 else if(attribute_name ==
"InnerClasses")
1754 const u2 methods_count = read<u2>();
1756 for(std::size_t j=0; j<methods_count; j++)
1760 #define ACC_PUBLIC 0x0001u
1761 #define ACC_PRIVATE 0x0002u
1762 #define ACC_PROTECTED 0x0004u
1763 #define ACC_STATIC 0x0008u
1764 #define ACC_FINAL 0x0010u
1765 #define ACC_VARARGS 0x0080u
1766 #define ACC_SUPER 0x0020u
1767 #define ACC_VOLATILE 0x0040u
1768 #define ACC_TRANSIENT 0x0080u
1769 #define ACC_INTERFACE 0x0200u
1770 #define ACC_ABSTRACT 0x0400u
1771 #define ACC_SYNTHETIC 0x1000u
1772 #define ACC_ANNOTATION 0x2000u
1773 #define ACC_ENUM 0x4000u
1779 const u2 access_flags = read<u2>();
1780 const u2 name_index = read<u2>();
1781 const u2 descriptor_index = read<u2>();
1798 const auto flags = (method.
is_public ? 1 : 0) +
1801 DATA_INVARIANT(flags<=1,
"at most one of public, protected, private");
1802 const u2 attributes_count = read<u2>();
1804 for(std::size_t j=0; j<attributes_count; j++)
1809 std::istream &istream,
1812 bool skip_instructions)
1815 skip_instructions, message_handler);
1816 java_bytecode_parser.
in=&istream;
1818 bool parser_result=java_bytecode_parser.
parse();
1827 return std::move(java_bytecode_parser.
parse_tree);
1831 const std::string &file,
1834 bool skip_instructions)
1844 in, class_name, message_handler, skip_instructions);
1852 const u2 local_variable_type_table_length = read<u2>();
1856 "Local variable type table cannot have more elements "
1857 "than the local variable table.");
1858 for(std::size_t i=0; i<local_variable_type_table_length; i++)
1860 const u2 start_pc = read<u2>();
1861 const u2 length = read<u2>();
1862 const u2 name_index = read<u2>();
1863 const u2 signature_index = read<u2>();
1864 const u2 index = read<u2>();
1870 if(lvar.index==index &&
1872 lvar.start_pc==start_pc &&
1873 lvar.length==length)
1882 "Entry in LocalVariableTypeTable must be present in LVT");
1895 switch(java_handle_kind)
1919 std::optional<java_bytecode_parsert::lambda_method_handlet>
1958 std::string descriptor = name_and_type.
get_descriptor(pool_entry_lambda);
1966 method_type, mangled_method_name, class_name, method_name};
1975 const u2 num_bootstrap_methods = read<u2>();
1976 for(
size_t bootstrap_method_index = 0;
1977 bootstrap_method_index < num_bootstrap_methods;
1978 ++bootstrap_method_index)
1980 const u2 bootstrap_methodhandle_ref = read<u2>();
1985 const u2 num_bootstrap_arguments = read<u2>();
1986 log.
debug() <<
"INFO: parse BootstrapMethod handle "
1990 std::vector<u2> u2_values(num_bootstrap_arguments);
1991 for(
size_t i = 0; i < num_bootstrap_arguments; i++)
1992 u2_values[i] = read<u2>();
2024 if(num_bootstrap_arguments < 3)
2028 <<
"format of BootstrapMethods entry not recognized: too few arguments"
2033 u2 interface_type_index = u2_values[0];
2034 u2 method_handle_index = u2_values[1];
2035 u2 method_type_index = u2_values[2];
2041 bool recognized =
true;
2042 for(
size_t i = 3; i < num_bootstrap_arguments; i++)
2044 u2 skipped_argument = u2_values[i];
2050 log.
debug() <<
"format of BootstrapMethods entry not recognized: extra "
2051 "arguments of wrong type"
2068 <<
"format of BootstrapMethods entry not recognized: arguments "
2081 log.
debug() <<
"format of BootstrapMethods entry not recognized: method "
2082 "handle not recognised"
2093 <<
"lambda function reference "
2097 <<
"\n interface type is "
2099 <<
"\n method type is "
2110 size_t bootstrap_method_index)
struct bytecode_infot const bytecode_info[]
Array constructor from list of elements.
class_infot get_class(const pool_entry_lookupt &pool_entry) const
name_and_type_infot get_name_and_type(const pool_entry_lookupt &pool_entry) const
u2 get_class_index() const
u2 get_name_and_type_index() const
base_ref_infot(const pool_entryt &entry)
Corresponds to the CONSTANT_Class_info Structure Described in Java 8 specification 4....
class_infot(const pool_entryt &entry)
std::string get_name(const pool_entry_lookupt &pool_entry) const
An expression describing a method on a class.
const typet & return_type() const
const parameterst & parameters() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const char * c_str() const
Base class for all expressions.
std::vector< exprt > operandst
typet & type()
Return the type of the expression.
const irep_idt & get(const irep_idt &name) const
const irep_idt & id() const
void get_annotation_class_refs(const std::vector< annotationt > &annotations)
For each of the given annotations, get a reference to its class and recursively get class references ...
void store_unknown_method_handle(size_t bootstrap_method_index)
Creates an unknown method handle and puts it into the parsed_class.
exprt get_relement_value()
Corresponds to the element_value structure Described in Java 8 specification 4.7.16....
java_bytecode_parse_treet::annotationt annotationt
java_bytecode_parse_treet::methodt methodt
exprt & constant(u2 index)
void rRuntimeAnnotation_attribute(std::vector< annotationt > &)
const typet type_entry(u2 index)
void rfield_attribute(fieldt &)
void rbytecode(std::vector< instructiont > &)
void rcode_attribute(methodt &method)
void read_bootstrapmethods_entry()
Read all entries of the BootstrapMethods attribute of a class file.
void get_class_refs()
Get the class references for the benefit of a dependency analysis.
void get_annotation_value_class_refs(const exprt &value)
See java_bytecode_parsert::get_annotation_class_refs.
java_bytecode_parse_treet parse_tree
std::vector< pool_entryt > constant_poolt
java_bytecode_parsert(bool skip_instructions, message_handlert &message_handler)
void skip_bytes(std::size_t bytes)
void read_verification_type_info(methodt::verification_type_infot &)
java_bytecode_parse_treet::fieldt fieldt
pool_entryt & pool_entry(u2 index)
constant_poolt constant_pool
void get_class_refs_rec(const typet &)
void parse_local_variable_type_table(methodt &method)
Parses the local variable type table of a method.
const bool skip_instructions
void rRuntimeAnnotation(annotationt &)
std::optional< lambda_method_handlet > parse_method_handle(const class method_handle_infot &entry)
Read method handle pointed to from constant pool entry at index, return type of method handle and nam...
void relement_value_pairs(annotationt::element_value_pairst &)
void rinner_classes_attribute(const u4 &attribute_length)
Corresponds to the element_value structure Described in Java 8 specification 4.7.6 https://docs....
std::vector< irep_idt > rexceptions_attribute()
Corresponds to the element_value structure Described in Java 8 specification 4.7.5 https://docs....
void rmethod_attribute(methodt &method)
method_handle_kindt
Indicates what sort of code should be synthesised for a lambda call:
@ LAMBDA_STATIC_METHOD_HANDLE
Direct call to the given method.
@ LAMBDA_VIRTUAL_METHOD_HANDLE
Virtual call to the given interface or method.
@ UNKNOWN_HANDLE
Can't be called.
@ LAMBDA_CONSTRUCTOR_HANDLE
Instantiate the needed type then call a constructor.
method_handle_infot(const pool_entryt &entry)
base_ref_infot get_reference(const pool_entry_lookupt &pool_entry) const
method_handle_kindt handle_kind
method_handle_kindt get_handle_kind() const
method_handle_kindt
Correspond to the different valid values for field handle_kind From Java 8 spec 4....
Corresponds to the CONSTANT_NameAndType_info Structure Described in Java 8 specification 4....
name_and_type_infot(const pool_entryt &entry)
std::string get_descriptor(const pool_entry_lookupt &pool_entry) const
std::string get_name(const pool_entry_lookupt &pool_entry) const
Fixed-width bit-vector with two's complement interpretation.
const irep_idt & get_function() const
void set_java_bytecode_index(const irep_idt &index)
void set_line(const irep_idt &line)
void set_function(const irep_idt &function)
A struct tag type, i.e., struct_typet with an identifier.
Structure type, corresponds to C style structs.
const componentst & components() const
std::function< pool_entryt &(u2)> pool_entry_lookupt
static std::string read_utf8_constant(const pool_entryt &entry)
structured_pool_entryt(const pool_entryt &entry)
static symbol_exprt typeless(const irep_idt &id)
Generate a symbol_exprt without a proper type.
const irep_idt & get_identifier() const
An expression denoting a type.
The type of an expression, extends irept.
Fixed-width bit-vector with unsigned binary interpretation.
const std::string & id2string(const irep_idt &d)
#define CONSTANT_Fieldref
#define VTYPE_INFO_DOUBLE
#define CONSTANT_InvokeDynamic
#define CONSTANT_Methodref
#define CONSTANT_NameAndType
#define VTYPE_INFO_OBJECT
#define CONSTANT_MethodType
#define VTYPE_INFO_INTEGER
static java_class_typet::method_handle_kindt get_method_handle_type(method_handle_infot::method_handle_kindt java_handle_kind)
Translate the lambda method reference kind in a class file into the kind of handling the method requi...
#define VTYPE_INFO_UNINIT
#define CONSTANT_InterfaceMethodref
#define VTYPE_INFO_UNINIT_THIS
std::optional< java_bytecode_parse_treet > java_bytecode_parse(std::istream &istream, const irep_idt &class_name, message_handlert &message_handler, bool skip_instructions)
Attempt to parse a Java class from the given stream.
#define CONSTANT_MethodHandle
#define VTYPE_INFO_ITEM_NULL
Representation of a constant Java string.
void get_dependencies_from_generic_parameters(const std::string &signature, std::set< irep_idt > &refs)
Collect information about generic type parameters from a given signature.
struct_tag_typet java_classname(const std::string &id)
const typet & java_array_element_type(const struct_tag_typet &array_symbol)
Return a const reference to the element type of a given java array type.
std::optional< typet > java_type_from_string(const std::string &src, const std::string &class_name_prefix)
Transforms a string representation of a Java type into an internal type representation thereof.
bool is_java_array_tag(const irep_idt &tag)
See above.
const java_method_typet & to_java_method_type(const typet &type)
std::optional< typet > java_type_from_string_with_exception(const std::string &descriptor, const std::optional< std::string > &signature, const std::string &class_name)
static std::string binary(const constant_exprt &src)
static std::optional< java_class_typet::java_lambda_method_handlet > lambda_method_handle(const symbol_table_baset &symbol_table, const irep_idt &method_identifier, const java_method_typet &dynamic_method_type)
java_bytecode_parse_treet::classt::lambda_method_handlet lambda_method_handlet
java_bytecode_parse_treet::methodt methodt
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
#define POSTCONDITION(CONDITION)
API to expression classes.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
void replace(const union_find_replacet &replace_map, string_not_contains_constraintt &constraint)
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
std::vector< element_value_pairt > element_value_pairst
element_value_pairst element_value_pairs
static lambda_method_handlet get_unknown_handle()
std::optional< std::string > signature
bool attribute_bootstrapmethods_read
void add_method_handle(size_t bootstrap_index, const lambda_method_handlet &handle)
source_locationt source_location
std::optional< std::string > signature
@ SAME_LOCALS_ONE_STACK_EXTENDED
verification_type_info_type type
exception_tablet exception_table
std::vector< annotationst > parameter_annotations
Java annotations that were applied to parameters of this method.
source_locationt source_location
stack_map_tablet stack_map_table
instructionst instructions
local_variable_tablet local_variable_table
std::vector< irep_idt > throws_exception_table