Skip to content

Parameter Conversion Bypass for JsonValue[] Array Types #26

@javier-godoy

Description

@javier-godoy

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.

if (hasJsonValueParams && JsonValue.class.isAssignableFrom(paramType)) {

Expected behavior

  1. Type Detection: The bytecode generator correctly identifies parameters that are arrays of JsonValue or its subtypes (e.g., JsonObject[], JsonArray[]).
  2. 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.
  3. Successful Conversion: The instrumented method iterates through the source Jackson JsonNode array, converts each element using the version-specific migration logic, and populates the destination array.
  4. Stack Integrity: After conversion, the stack contains a reference to the fully populated Elemental array, allowing the super method 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

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions