From b673ebbc7c0cdae22c5e09f143aa7b79f8d8d14a Mon Sep 17 00:00:00 2001 From: Thomas Spriggs Date: Wed, 4 Apr 2018 15:15:33 +0100 Subject: [PATCH] Add storage of final modifier status of java classes in `java_class_typet`. --- src/java_bytecode/java_bytecode_convert_class.cpp | 1 + src/java_bytecode/java_bytecode_parse_tree.cpp | 1 + src/java_bytecode/java_bytecode_parse_tree.h | 1 + src/java_bytecode/java_bytecode_parser.cpp | 1 + src/java_bytecode/java_types.h | 10 ++++++++++ src/util/irep_ids.def | 1 + 6 files changed, 15 insertions(+) diff --git a/src/java_bytecode/java_bytecode_convert_class.cpp b/src/java_bytecode/java_bytecode_convert_class.cpp index 0614380d74d..178dddad5ea 100644 --- a/src/java_bytecode/java_bytecode_convert_class.cpp +++ b/src/java_bytecode/java_bytecode_convert_class.cpp @@ -265,6 +265,7 @@ void java_bytecode_convert_classt::convert( class_type.set_tag(c.name); class_type.set(ID_base_name, c.name); class_type.set(ID_abstract, c.is_abstract); + class_type.set_final(c.is_final); if(c.is_enum) { if(max_array_length != 0 && c.enum_elements > max_array_length) diff --git a/src/java_bytecode/java_bytecode_parse_tree.cpp b/src/java_bytecode/java_bytecode_parse_tree.cpp index 5b73a88e911..08eebadcb8e 100644 --- a/src/java_bytecode/java_bytecode_parse_tree.cpp +++ b/src/java_bytecode/java_bytecode_parse_tree.cpp @@ -29,6 +29,7 @@ void java_bytecode_parse_treet::classt::swap( std::swap(other.is_public, is_public); std::swap(other.is_protected, is_protected); std::swap(other.is_private, is_private); + std::swap(other.is_final, is_final); std::swap(other.signature, signature); other.implements.swap(implements); other.fields.swap(fields); diff --git a/src/java_bytecode/java_bytecode_parse_tree.h b/src/java_bytecode/java_bytecode_parse_tree.h index 7e583af3673..829856c5b0b 100644 --- a/src/java_bytecode/java_bytecode_parse_tree.h +++ b/src/java_bytecode/java_bytecode_parse_tree.h @@ -182,6 +182,7 @@ class java_bytecode_parse_treet bool is_abstract=false; bool is_enum=false; bool is_public=false, is_protected=false, is_private=false; + bool is_final = false; bool attribute_bootstrapmethods_read = false; size_t enum_elements=0; diff --git a/src/java_bytecode/java_bytecode_parser.cpp b/src/java_bytecode/java_bytecode_parser.cpp index 1a0a4d26627..db44f7c5b74 100644 --- a/src/java_bytecode/java_bytecode_parser.cpp +++ b/src/java_bytecode/java_bytecode_parser.cpp @@ -495,6 +495,7 @@ void java_bytecode_parsert::rClassFile() parsed_class.is_public=(access_flags&ACC_PUBLIC)!=0; parsed_class.is_protected=(access_flags&ACC_PROTECTED)!=0; parsed_class.is_private=(access_flags&ACC_PRIVATE)!=0; + parsed_class.is_final = (access_flags & ACC_FINAL) != 0; parsed_class.name= constant(this_class).type().get(ID_C_base_name); diff --git a/src/java_bytecode/java_types.h b/src/java_bytecode/java_types.h index e86fe24799c..22cfcc9f530 100644 --- a/src/java_bytecode/java_types.h +++ b/src/java_bytecode/java_types.h @@ -111,6 +111,16 @@ class java_class_typet:public class_typet return set(ID_access, access); } + bool get_final() + { + return get_bool(ID_final); + } + + void set_final(bool is_final) + { + set(ID_final, is_final); + } + typedef std::vector java_lambda_method_handlest; const java_lambda_method_handlest &lambda_method_handles() const diff --git a/src/util/irep_ids.def b/src/util/irep_ids.def index b0fac1ce788..04fcb8df985 100644 --- a/src/util/irep_ids.def +++ b/src/util/irep_ids.def @@ -667,6 +667,7 @@ IREP_ID_TWO(C_no_initialization_required, #no_initialization_required) IREP_ID_TWO(overlay_class, java::com.diffblue.OverlayClassImplementation) IREP_ID_TWO(overlay_method, java::com.diffblue.OverlayMethodImplementation) IREP_ID_TWO(C_annotations, #annotations) +IREP_ID_ONE(final) // Projects depending on this code base that wish to extend the list of // available ids should provide a file local_irep_ids.h in their source tree and