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