-
Notifications
You must be signed in to change notification settings - Fork 0
fix: convert JsonValue in varargs methods and fix: invoke executeJs using reflection #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds version-aware reflective dispatch for Element.executeJs and updates JsonMigrationHelper25 to convert trailing varargs Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main/java/com/flowingcode/vaadin/jsonmigration/JsonMigration.java(2 hunks)src/main/java/com/flowingcode/vaadin/jsonmigration/JsonMigrationHelper25.java(3 hunks)
🔇 Additional comments (1)
src/main/java/com/flowingcode/vaadin/jsonmigration/JsonMigration.java (1)
119-128: Reflection-basedexecuteJsdispatch looks consistent; just double-check Vaadin signaturesThe lookup for
Element.executeJsand the wrapper that delegates viahelper.invokeare coherent with the stated goal of handling(String, Object...)for Vaadin > 24 and(String, Serializable...)otherwise. No obvious issues in the reflection wiring itself.Please just verify against the exact Flow 24/25
Element.executeJssignatures you support (parameter and return types) to ensure the reflective lookup remains stable across versions.Also applies to: 142-143
src/main/java/com/flowingcode/vaadin/jsonmigration/JsonMigrationHelper25.java
Show resolved
Hide resolved
src/main/java/com/flowingcode/vaadin/jsonmigration/JsonMigrationHelper25.java
Show resolved
Hide resolved
da0d305 to
fb2ae68
Compare
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/java/com/flowingcode/vaadin/jsonmigration/JsonMigrationHelper25.java (1)
63-72: Consider adding defensive bounds check for parameterTypes array access.While all current call sites are safe, line 67 accesses
parameterTypes[j]without verifyingj < parameterTypes.length. Adding this check would make the code more robust against potential future misuse:- if (method.isVarArgs() && j >= 0 && args[j] instanceof Object[]) { + if (method.isVarArgs() && j >= 0 && j < parameterTypes.length && args[j] instanceof Object[]) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main/java/com/flowingcode/vaadin/jsonmigration/JsonMigration.java(2 hunks)src/main/java/com/flowingcode/vaadin/jsonmigration/JsonMigrationHelper25.java(3 hunks)
🔇 Additional comments (3)
src/main/java/com/flowingcode/vaadin/jsonmigration/JsonMigration.java (2)
119-128: LGTM! Version-aware method lookup follows established patterns.The reflective dispatch logic correctly selects the appropriate
Element.executeJssignature based on Vaadin version, mirroring the pattern used for other version-sensitive methods in this class.
142-143: The original review concern is based on incorrect API assumptions.Both Vaadin 24 and Vaadin 25 use the same method signature:
public PendingJavaScriptResult executeJs(String expression, Serializable... parameters). The original review expected different signatures (Object[] vs Serializable[]), but both versions actually use varargs with identical parameter types. The reflective invocation at lines 142-143 correctly passes the parameters array to this signature.Likely an incorrect or invalid review comment.
src/main/java/com/flowingcode/vaadin/jsonmigration/JsonMigrationHelper25.java (1)
90-114: LGTM! Array conversion logic is correct.The
convertArraymethod properly handles conversion ofJsonValueelements toBaseJsonNodewithin varargs arrays. The prefix copy on line 101 correctly usesias the length, preserving all elements before the first converted one. The lazy initialization and mixed-type handling are both appropriate.
Summary by CodeRabbit