@@ -2106,6 +2106,21 @@ void java_bytecode_convert_methodt::convert_invoke(
2106
2106
code_typet &code_type = to_code_type (arg0.type ());
2107
2107
code_typet::parameterst ¶meters (code_type.parameters ());
2108
2108
2109
+ const std::string full_method_name = id2string (method_id);
2110
+ const size_t method_separator = id2string (method_id).rfind (' :' );
2111
+ const std::string method_name = full_method_name.substr (0 , method_separator);
2112
+
2113
+ const size_t class_separator = method_name.rfind (' .' );
2114
+ const std::string calling_class_name = method_name.substr (0 , class_separator);
2115
+
2116
+ std::string class_type_name = calling_class_name.substr (6 );
2117
+ std::replace (class_type_name.begin (), class_type_name.end (), ' .' , ' /' );
2118
+ const auto &enum_clone_symbol = symbol_table.lookup_ref (calling_class_name);
2119
+ const bool is_enum_values_clone_call =
2120
+ enum_clone_symbol.type .get_bool (ID_enumeration) &&
2121
+ (full_method_name ==
2122
+ (calling_class_name + " .values:()[L" + class_type_name + " ;" ));
2123
+
2109
2124
if (use_this)
2110
2125
{
2111
2126
if (parameters.empty () || !parameters[0 ].get_this ())
@@ -2197,7 +2212,7 @@ void java_bytecode_convert_methodt::convert_invoke(
2197
2212
// generate code that may wrongly assume that such a method is
2198
2213
// accessible if we assume that its access attribute is "more
2199
2214
// accessible" than it actually is.
2200
- irep_idt id = arg0.get (ID_identifier);
2215
+ const irep_idt id = arg0.get (ID_identifier);
2201
2216
if (
2202
2217
symbol_table.symbols .find (id) == symbol_table.symbols .end () &&
2203
2218
!(is_virtual &&
@@ -2220,7 +2235,13 @@ void java_bytecode_convert_methodt::convert_invoke(
2220
2235
symbol_table.add (symbol);
2221
2236
}
2222
2237
2223
- if (is_virtual)
2238
+ if (is_enum_values_clone_call)
2239
+ {
2240
+ const std::string clone_name =
2241
+ " java::array[" + calling_class_name + " ].clone:()Ljava/lang/Object;" ;
2242
+ call.function () = symbol_exprt (clone_name, arg0.type ());
2243
+ }
2244
+ else if (is_virtual)
2224
2245
{
2225
2246
// dynamic binding
2226
2247
assert (use_this);
0 commit comments