Skip to content

feat: Add bean serialization support - #22378

Merged
Artur- merged 18 commits into
mainfrom
json-bean
Oct 1, 2025
Merged

Artur- merged 18 commits into
mainfrom
json-bean

Conversation

@Artur-

@Artur- Artur- commented Sep 30, 2025

Copy link
Copy Markdown
Member

Implements bean-only serialization using Jackson.
Beans are serialized on server and handled as standard JS objects on client.

Artur- and others added 4 commits September 30, 2025 13:11
Implements bean-only serialization using Jackson with BEAN_TYPE=5 wrapper.
Beans are serialized on server and handled as standard JS objects on client.

- Add BEAN_TYPE constant to JacksonCodec and JsonCodec
- Implement bean encoding for Serializable objects using Jackson
- Update canEncodeWithTypeInfo to include Serializable beans
- Add comprehensive unit tests in JacksonCodecTest
- Add integration tests for simple and nested bean scenarios

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Changes all JavaScript execution APIs to accept any Object type instead of
requiring Serializable, enabling bean serialization for any object.

- Update Element.executeJs() and callJsFunction() to accept Object...
- Update Page.executeJs() to accept Object...
- Update JavaScriptInvocation to use Object... parameters
- Fix null value handling in encodeWithTypeInfo methods
- Update all javadoc references to reflect Object parameter types
- Update test method signatures and variable types
- Modify unsupported types test to verify beans are now encoded properly
- Add test for non-Serializable objects being encoded as beans

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove BEAN_TYPE constant and wrapper logic from both JsonCodec and JacksonCodec
- Serialize beans directly as JSON objects without type information
- Update tests to expect direct JSON objects instead of type-wrapped arrays
- Fix PolymerTemplateTest compilation error with Object... parameter types

This simplifies the implementation while maintaining full bean serialization
functionality for executeJs APIs.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove canEncodeWithTypeInfo from both JsonCodec and JacksonCodec as it always returned true
- Remove related assert statements that were no longer meaningful
- Simplify ClientCallableHandlers validation since all types are now supported
- Clean up unused validation logic for client-callable method return types

Since we now support encoding any object type as a bean, the type validation
is no longer needed.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Artur-
Artur- requested a review from Legioth September 30, 2025 11:32
Artur- and others added 4 commits September 30, 2025 15:03
- Fix JavaScriptBootstrapUITest argument captors to expect Object[] instead of Serializable[]
- Fix HotswapperTest Mockito mock to expect Object[].class instead of Serializable[].class
- Update variable types in tests to match new executeJs signature (Object... vs Serializable...)

These changes are required after updating executeJs method signatures to accept
Object instead of Serializable parameters.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add deprecated Page.executeJs(String, Serializable[]) overload
- Add deprecated Element.executeJs(String, Serializable[]) overload
- Add deprecated Element.callJsFunction(String, Serializable[]) overload

These methods delegate to the new Object[] variants and ensure that existing
compiled code continues to work without recompilation. The deprecated methods
will be removed in a future major version.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ally

- Update Page.executeJs javadoc to state general Jackson support instead of listing specific types
- Update Element.executeJs javadoc to state general Jackson support instead of listing specific types
- Update Element.callJsFunction javadoc to state general Jackson support instead of listing specific types
- Only mention special cases (Element and BaseJsonNode) that have unique behavior
- Remove redundant type listings that are hard to maintain and don't capture full capability

This makes the documentation more accurate and easier to maintain as Jackson
supports a wide variety of types for JSON serialization.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Rename test method from encodeWithTypeInfo_formerlyUnsupportedTypesNowEncodedAsBeans to encodeWithTypeInfo_complexTypesEncodedAsBeans
- Rename test variable from withTypeInfoUnsupportedValues to complexTypeValues
- Update comments to describe current behavior rather than historical comparisons
- Remove "formerly", "previously", "now" references that don't make sense outside PR context

Names and comments should reflect how the system currently works, not how it used to work.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 30, 2025 •

Copy link
Copy Markdown
Contributor

Test Results

1 268 files  1 268 suites   1h 15m 19s ⏱️
8 683 tests 8 616 ✅ 67 💤 0 ❌
9 142 runs  9 068 ✅ 74 💤 0 ❌

Results for commit faa61f0.

♻️ This comment has been updated with latest results.

Artur- and others added 6 commits September 30, 2025 15:35
…n tests

- Remove redundant testNonSerializableBeanSerialization test
- Make test bean classes non-Serializable to demonstrate broader Object support
- Merge encodeWithTypeInfo_complexTypesEncodedAsBeans into existing test
- Consolidate bean serialization UI tests to reduce noise:
  - Replace separate simple/nested bean buttons with single bean test
  - Combine testSimpleBean and testNestedBean into one method
  - Update integration test to verify both bean types in single execution

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Moved the void return type validation from AbstractServerHandlers to
PolymerServerEventHandlers where it's actually needed. The base class
now has an empty default implementation allowing all return types.
Removed redundant override in ClientCallableHandlers.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
tepi
tepi previously approved these changes Oct 1, 2025
Improve documentation for Element parameters in executeJs and callJsFunction methods:
- Restore parentheses around special cases for better readability
- Clarify that Elements are sent as DOM element references (not Jackson serialization)
- Explain attached vs unattached behavior more clearly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Artur- and others added 3 commits October 1, 2025 09:46
…mplex types

Replace weak assertions that only checked for "not null and valid JSON" with comprehensive
tests that verify the actual JSON structure and content for each complex type:

- Object: Verifies serialization as empty JSON object
- StateNode: Verifies serialization as JSON object with properties
- Date: Verifies timestamp serialization with correct value
- Arrays and Collections: Verifies correct JSON array structure and content
- HashMap: Verifies JSON object structure with correct key-value pairs

Tests now provide meaningful validation of Jackson serialization behavior rather than
just confirming "it doesn't crash".

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Artur-
Artur- enabled auto-merge (squash) October 1, 2025 06:59
@sonarqubecloud

sonarqubecloud Bot commented Oct 1, 2025

Copy link
Copy Markdown

@Artur-
Artur- merged commit 7af11a8 into main Oct 1, 2025
@Artur-
Artur- deleted the json-bean branch October 1, 2025 07:09
Copilot AI pushed a commit that referenced this pull request Oct 1, 2025
Implements bean-only serialization using Jackson.
Beans are serialized on server and handled as standard JS objects on client.
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 25.0.0-beta2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants