Skip to content

Commit 19e5bba

Browse files
committed
Document synthetic methods generated by the Java frontend
1 parent 442f315 commit 19e5bba

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/java_bytecode/java_bytecode_language.h

+4
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ class java_bytecode_languaget:public languaget
172172

173173
private:
174174
const std::unique_ptr<const select_pointer_typet> pointer_type_selector;
175+
176+
/// Maps synthetic method names on to the particular type of synthetic method
177+
/// (static initializer, initializer wrapper, etc). For full documentation see
178+
/// synthetic_method_map.h
175179
synthetic_methods_mapt synthetic_methods;
176180
stub_global_initializer_factoryt stub_global_initializer_factory;
177181
class_hierarchyt class_hierarchy;

src/java_bytecode/synthetic_methods_map.h

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************\
22
3-
Module: Java Static Initializers
3+
Module: Synthetic methods map
44
55
Author: Chris Smowton, [email protected]
66
@@ -9,12 +9,31 @@ Author: Chris Smowton, [email protected]
99
#ifndef CPROVER_JAVA_BYTECODE_SYNTHETIC_METHODS_MAP_H
1010
#define CPROVER_JAVA_BYTECODE_SYNTHETIC_METHODS_MAP_H
1111

12+
/// \file
13+
/// Synthetic methods are particular methods internally generated by the
14+
/// Java frontend, including thunks to ensure static initializers are run once
15+
/// and initializers created for unknown / stub types. Compare normal methods,
16+
/// which are translated from Java bytecode. This file provides an
17+
/// enumeration specifying the kind of a particular synthetic method and a
18+
/// common type of a map giving a collection of synthetic methods.
19+
/// Functions stubs and array.clone() functions are also generated by the Java
20+
/// frontend but are not recorded using this framework, but may be in future.
21+
22+
/// Synthetic method kinds.
1223
enum class synthetic_method_typet
1324
{
25+
/// A static initializer wrapper
26+
/// (code of the form `if(!already_run) clinit(); already_run = true;`)
27+
/// These are generated for both user and stub types, to ensure the actual
28+
/// static initializer is only run once on any given path.
1429
STATIC_INITIALIZER_WRAPPER,
30+
/// A generated (synthetic) static initializer function for a stub type.
31+
/// Because we don't have the bytecode for a stub type (by definition), we
32+
/// generate a static initializer function to initialize its static fields.
1533
STUB_CLASS_STATIC_INITIALIZER
1634
};
1735

36+
/// Maps method names on to a synthetic method kind.
1837
typedef std::unordered_map<irep_idt, synthetic_method_typet, irep_id_hash>
1938
synthetic_methods_mapt;
2039

0 commit comments

Comments
 (0)