Skip to content

Commit c0c1029

Browse files
Fixes parsing for anonymous classes
1 parent 1930aef commit c0c1029

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

jbmc/src/java_bytecode/java_bytecode_parser.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,8 @@ void java_bytecode_parsert::relement_value_pair(
15881588
/// in its inner class array. If the parsed class is not an inner class, then it
15891589
/// is ignored. When a parsed class is an inner class, the accessibility
15901590
/// information for the parsed class is overwritten, and the parsed class is
1591-
/// marked as an inner class.
1591+
/// marked as an inner class. Note that is outer_class_info_index == 0, the
1592+
/// inner class is an anonymous or local class, and is treated as private.
15921593
void java_bytecode_parsert::rinner_classes_attribute(
15931594
classt &parsed_class,
15941595
const u4 &attribute_length)
@@ -1631,7 +1632,17 @@ void java_bytecode_parsert::rinner_classes_attribute(
16311632
parsed_class.is_inner_class =
16321633
remove_separator_char(id2string(parsed_class.name), '.') ==
16331634
remove_separator_char(inner_class_info_name, '/');
1634-
if(parsed_class.is_inner_class)
1635+
if(!parsed_class.is_inner_class)
1636+
continue;
1637+
if(outer_class_info_index == 0)
1638+
{
1639+
// This is a marker for an anonymous or local class
1640+
// which are treated as private
1641+
parsed_class.is_private = true;
1642+
parsed_class.is_protected = false;
1643+
parsed_class.is_public = false;
1644+
}
1645+
else
16351646
{
16361647
parsed_class.is_private = is_private;
16371648
parsed_class.is_protected = is_protected;

0 commit comments

Comments
 (0)