@@ -1640,6 +1640,48 @@ void java_bytecode_parsert::rclass_attribute(classt &parsed_class)
1640
1640
parsed_class.attribute_bootstrapmethods_read = true ;
1641
1641
read_bootstrapmethods_entry (parsed_class);
1642
1642
}
1643
+ else if (attribute_name == " InnerClasses" )
1644
+ {
1645
+ u2 number_of_classes = read_u2 ();
1646
+ u4 number_of_bytes_to_be_read = number_of_classes * 8 + 2 ;
1647
+ INVARIANT (
1648
+ number_of_bytes_to_be_read == attribute_length,
1649
+ " The number of bytes to be read for the InnerClasses attribute does not "
1650
+ " match the attribute length." );
1651
+
1652
+ const std::function<pool_entryt &(u2)> pool_entry_lambda =
1653
+ [this ](u2 index ) -> pool_entryt & { return pool_entry (index ); };
1654
+ std::function<std::string (std::string, char )> remove_separator_char =
1655
+ [](std::string str, char ch) {
1656
+ str.erase (std::remove (str.begin (), str.end (), ch), str.end ());
1657
+ return str;
1658
+ };
1659
+
1660
+ for (int i = 0 ; i < number_of_classes; i++)
1661
+ {
1662
+ u2 inner_class_info_index = read_u2 ();
1663
+ UNUSED u2 outer_class_info_index = read_u2 ();
1664
+ UNUSED u2 inner_name_index = read_u2 ();
1665
+ u2 inner_class_access_flags = read_u2 ();
1666
+
1667
+ if (inner_class_info_index != 0 )
1668
+ {
1669
+ std::string inner_class_info_name =
1670
+ class_infot (pool_entry (inner_class_info_index))
1671
+ .get_name (pool_entry_lambda);
1672
+ UNUSED bool is_private = inner_class_access_flags & ACC_PRIVATE;
1673
+ UNUSED bool is_public = inner_class_access_flags & ACC_PUBLIC;
1674
+ UNUSED bool is_protected = inner_class_access_flags & ACC_PROTECTED;
1675
+
1676
+ // If the original parsed class name matches the inner class name
1677
+ // the parsed class is an inner class, so overwrite the parsed class'
1678
+ // access information and mark it as an inner class
1679
+ UNUSED bool is_inner_class =
1680
+ remove_separator_char (id2string (parsed_class.name ), ' .' ) ==
1681
+ remove_separator_char (inner_class_info_name, ' /' );
1682
+ }
1683
+ }
1684
+ }
1643
1685
else
1644
1686
skip_bytes (attribute_length);
1645
1687
}
0 commit comments