@@ -2120,6 +2120,30 @@ exprt::operandst &java_bytecode_convert_methodt::convert_const(
2120
2120
return results;
2121
2121
}
2122
2122
2123
+ static void adjust_invoke_argument_types (
2124
+ const java_method_typet::parameterst ¶meters,
2125
+ code_function_callt::argumentst &arguments)
2126
+ {
2127
+ // do some type adjustment for the arguments,
2128
+ // as Java promotes arguments
2129
+ // Also cast pointers since intermediate locals
2130
+ // can be void*.
2131
+ INVARIANT (
2132
+ parameters.size () == arguments.size (),
2133
+ " for each parameter there must be exactly one argument" );
2134
+ for (std::size_t i = 0 ; i < parameters.size (); i++)
2135
+ {
2136
+ const typet &type = parameters[i].type ();
2137
+ if (
2138
+ type == java_boolean_type () || type == java_char_type () ||
2139
+ type == java_byte_type () || type == java_short_type () ||
2140
+ type.id () == ID_pointer)
2141
+ {
2142
+ arguments[i] = typecast_exprt::conditional_cast (arguments[i], type);
2143
+ }
2144
+ }
2145
+ }
2146
+
2123
2147
void java_bytecode_convert_methodt::convert_invoke (
2124
2148
source_locationt location,
2125
2149
const irep_idt &statement,
@@ -2197,24 +2221,7 @@ void java_bytecode_convert_methodt::convert_invoke(
2197
2221
!use_this || arguments.front ().type ().id () == ID_pointer,
2198
2222
" first argument must be a pointer" );
2199
2223
2200
- // do some type adjustment for the arguments,
2201
- // as Java promotes arguments
2202
- // Also cast pointers since intermediate locals
2203
- // can be void*.
2204
- INVARIANT (
2205
- parameters.size () == arguments.size (),
2206
- " for each parameter there must be exactly one argument" );
2207
- for (std::size_t i = 0 ; i < parameters.size (); i++)
2208
- {
2209
- const typet &type = parameters[i].type ();
2210
- if (
2211
- type == java_boolean_type () || type == java_char_type () ||
2212
- type == java_byte_type () || type == java_short_type () ||
2213
- type.id () == ID_pointer)
2214
- {
2215
- arguments[i] = typecast_exprt::conditional_cast (arguments[i], type);
2216
- }
2217
- }
2224
+ adjust_invoke_argument_types (parameters, arguments);
2218
2225
2219
2226
// do some type adjustment for return values
2220
2227
exprt lhs = nil_exprt ();
@@ -3022,6 +3029,9 @@ optionalt<exprt> java_bytecode_convert_methodt::convert_invoke_dynamic(
3022
3029
// lambda_new.<init>(capture_1, capture_2, ...);
3023
3030
// Add the implicit 'this' parameter:
3024
3031
arguments.insert (arguments.begin (), new_instance);
3032
+ adjust_invoke_argument_types (
3033
+ to_code_type (constructor_symbol.type ).parameters (), arguments);
3034
+
3025
3035
code_function_callt constructor_call (
3026
3036
constructor_symbol.symbol_expr (), arguments);
3027
3037
constructor_call.add_source_location () = location;
0 commit comments