Skip to content

Commit 009ec58

Browse files
Matthias Güdemannmgudemann
Matthias Güdemann
authored andcommitted
read ACC_ABSTRACT attribute in Java class files
This adds the initialization of the `is_abstract` and `is_enum` Boolean values to the Java class file parser. It also adds setting the value of `is_abstract` which wasn't done before and could lead to undefined behaviour as an unitialized bool was read in `std::swap(other.is_abstract, is_abstract)`.
1 parent e7bf646 commit 009ec58

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/java_bytecode/java_bytecode_parse_tree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ void java_bytecode_parse_treet::classt::swap(
3434
{
3535
other.name.swap(name);
3636
other.extends.swap(extends);
37-
other.is_enum=is_enum;
38-
other.enum_elements=enum_elements;
37+
std::swap(other.is_enum, is_enum);
38+
std::swap(other.enum_elements, enum_elements);
3939
std::swap(other.is_abstract, is_abstract);
4040
other.implements.swap(implements);
4141
other.fields.swap(fields);

src/java_bytecode/java_bytecode_parse_tree.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ class java_bytecode_parse_treet
166166
{
167167
public:
168168
irep_idt name, extends;
169-
bool is_abstract;
170-
bool is_enum;
169+
bool is_abstract=false;
170+
bool is_enum=false;
171171
size_t enum_elements=0;
172172

173173
typedef std::list<irep_idt> implementst;

src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ void java_bytecode_parsert::rClassFile()
300300
u2 this_class=read_u2();
301301
u2 super_class=read_u2();
302302

303+
parsed_class.is_abstract=(access_flags&ACC_ABSTRACT)!=0;
303304
parsed_class.is_enum=(access_flags&ACC_ENUM)!=0;
304305
parsed_class.name=
305306
constant(this_class).type().get(ID_C_base_name);

0 commit comments

Comments
 (0)