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