Skip to content

Commit a129281

Browse files
fixup! Anonymous and local classes
1 parent f957036 commit a129281

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

jbmc/src/java_bytecode/java_bytecode_parser.cpp

+13-9
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)
@@ -1615,13 +1616,6 @@ void java_bytecode_parsert::rinner_classes_attribute(
16151616
UNUSED u2 inner_name_index = read_u2();
16161617
u2 inner_class_access_flags = read_u2();
16171618

1618-
if(inner_name_index == 0) {
1619-
// it is anonymous
1620-
parsed_class.is_private = true;
1621-
parsed_class.is_protected = false;
1622-
parsed_class.is_public = false;
1623-
}
1624-
16251619
if(inner_class_info_index == 0)
16261620
continue;
16271621

@@ -1638,7 +1632,17 @@ void java_bytecode_parsert::rinner_classes_attribute(
16381632
parsed_class.is_inner_class =
16391633
remove_separator_char(id2string(parsed_class.name), '.') ==
16401634
remove_separator_char(inner_class_info_name, '/');
1641-
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
16421646
{
16431647
parsed_class.is_private = is_private;
16441648
parsed_class.is_protected = is_protected;

0 commit comments

Comments
 (0)