-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Describe the bug
When a @LegacyClientCallable method contains parameters of type JsonValue[] (or specific subtypes like JsonObject[]), the bytecode transformation fails to convert the parameter.
The current logic only checks if a parameter is assignable from a scalar JsonValue. Because an array of JsonValue is not assignable to the scalar JsonValue class, the conversion is skipped. The logic then pushes the Jackson-backed array (e.g., JsonNode[]) onto the stack. This leads to a runtime failure when the super method is invoked, as the types on the stack do not match the expected Elemental JsonValue[] method signature.
JsonMigrationHelper/src/main/java/com/flowingcode/vaadin/jsonmigration/ClassInstrumentationUtil.java
Line 452 in bcb7201
| if (hasJsonValueParams && JsonValue.class.isAssignableFrom(paramType)) { |
Expected behavior
- Type Detection: The bytecode generator correctly identifies parameters that are arrays of
JsonValueor its subtypes (e.g.,JsonObject[],JsonArray[]). - Array Allocation: At runtime, the generated bytecode creates a new destination array of the exact component type required by the original method signature, ensuring the destination array's length matches the source Jackson array.
- Successful Conversion: The instrumented method iterates through the source Jackson
JsonNodearray, converts each element using the version-specific migration logic, and populates the destination array. - Stack Integrity: After conversion, the stack contains a reference to the fully populated Elemental array, allowing the
supermethod call to proceed.
Minimal reproducible example
public class LegacyClientCallable_ArrayOfJsonObject__V extends BaseClientCallable {
@LegacyClientCallable
public void test(JsonObject[] arg) {
assertThat(arg, notNullValue());
assertThat(arg, not(emptyArray()));
assertThat(arg, Matchers.instanceOf(JsonObject[].class));
trace();
}
}
Add-on Version
0.9.1-SNAPSHOT
Vaadin Version
25.0.0
Additional information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status