Skip to content

Fix Go RPC round-trip issues for Print path and delta encoding#7372

Merged
jkschneider merged 3 commits intomainfrom
jkschneider/go-rpc-fixes
Apr 14, 2026
Merged

Fix Go RPC round-trip issues for Print path and delta encoding#7372
jkschneider merged 3 commits intomainfrom
jkschneider/go-rpc-fixes

Conversation

@jkschneider
Copy link
Copy Markdown
Member

@jkschneider jkschneider commented Apr 14, 2026

Summary

  • 5 fixes for Go→Java→Go round-trip issues that caused recipe results to fail during the Print step (reverse GetObject). These complement the work merged in Go: load recipe modules as plugins for real execution #7263.

  • receiveReturn: store received expression in Return.Expressions instead of discarding it — fixes return x printing as return

  • receiveIf/sendIf: cache ControlParentheses wrapper in If.ConditionCP for stable delta encoding — fixes condition loss on NO_CHANGE round-trips

  • rightPaddedFromElement: prefer Expression over Statement for dual-interface types like MethodInvocation

  • GetObject.forceFullSend: when Go has no baseline for a tree ID, request a full ADD send from Java to avoid delta mismatches

  • StructTag: send tag as valueSource string instead of raw J.Literal that doesn't survive Objenesis round-trip

Test plan

  • All 60 Go integration tests pass (parser + recipe + auto-format)
  • mod build on 15 popular Go repos: zero RPC crashes
  • mod run recipes: zero Print-path errors

5 fixes for Go→Java→Go round-trip issues that caused recipe results
to fail during the Print step:

1. receiveReturn: store received expression in Return.Expressions
   instead of discarding it. Fixes `return x` printing as `return`.

2. receiveIf/sendIf: cache ControlParentheses wrapper in If.ConditionCP
   for stable delta encoding. Previously the synthetic CP was recreated
   with new UUIDs each send, and the receiver passed nil as "before",
   so NO_CHANGE returned nil and the condition was lost.

3. rightPaddedFromElement: prefer Expression over Statement for
   dual-interface types (like MethodInvocation). Most containers are
   expression containers; block bodies use coerceToStatementRP.

4. GetObject.forceFullSend: when Go has no baseline for a tree ID,
   request a full ADD send from Java to avoid delta mismatches between
   Go's original tree and Java's reconstructed version.

5. StructTag: send tag as valueSource string instead of raw J.Literal
   that doesn't survive Objenesis round-trip.
@jkschneider jkschneider force-pushed the jkschneider/go-rpc-fixes branch from 27c8749 to e2f7e39 Compare April 14, 2026 14:34
Parses actual Go files from 9 popular open-source repos (gorilla/mux,
spf13/cobra, sirupsen/logrus, go-chi/chi, gorilla/websocket,
gin-gonic/gin, spf13/viper, stretchr/testify, uber-go/zap) and
verifies both parse success and print round-trip fidelity.

Also removes the forceFullSend protocol hack from GetObject — the
field-level fixes (ConditionCP caching, Return expression storage,
StructTag serialization) make delta encoding work correctly without
needing to bypass it.
@jkschneider jkschneider merged commit bac73c4 into main Apr 14, 2026
1 check passed
@jkschneider jkschneider deleted the jkschneider/go-rpc-fixes branch April 14, 2026 15:33
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant