@@ -69,6 +69,11 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd)
6969 else
7070 lazy_methods_mode=LAZY_METHODS_MODE_EAGER;
7171
72+ if (cmd.isset (" java-threading" ))
73+ threading_support = true ;
74+ else
75+ threading_support = false ;
76+
7277 if (cmd.isset (" java-throw-runtime-exceptions" ))
7378 {
7479 throw_runtime_exceptions = true ;
@@ -701,7 +706,8 @@ bool java_bytecode_languaget::typecheck(
701706 // For each class that will require a static initializer wrapper, create a
702707 // function named package.classname::clinit_wrapper, and a corresponding
703708 // global tracking whether it has run or not:
704- create_static_initializer_wrappers (symbol_table, synthetic_methods);
709+ create_static_initializer_wrappers (
710+ symbol_table, synthetic_methods, threading_support);
705711
706712 // Now incrementally elaborate methods
707713 // that are reachable from this entry point.
@@ -961,7 +967,11 @@ bool java_bytecode_languaget::convert_single_method(
961967 switch (synthetic_method_it->second )
962968 {
963969 case synthetic_method_typet::STATIC_INITIALIZER_WRAPPER:
964- symbol.value = get_clinit_wrapper_body (function_id, symbol_table);
970+ if (threading_support)
971+ symbol.value = get_thread_safe_clinit_wrapper_body (
972+ function_id, symbol_table);
973+ else
974+ symbol.value = get_clinit_wrapper_body (function_id, symbol_table);
965975 break ;
966976 case synthetic_method_typet::STUB_CLASS_STATIC_INITIALIZER:
967977 symbol.value =
0 commit comments