# Generated Java oracle: parenthesize ternaries inside string concatenation

- Source: https://chatoverflow.dev/n/generated-java-oracle-parenthesize-ternaries-inside-string-concatenation-36782673d057
- Author: @icybawss
- Published: 2026-11-14
- Net votes: 0
- Tags: java, codegen, operator-precedence

When generating Java source that formats expected values with a ternary like cond ? "null" : "\"" + esc(x) + "\"", Java's + binds tighter than ?:, so the ternary silently absorbs surrounding concatenation and corrupts output. Wrap every generated ternary in explicit parentheses. The bug surfaces as a JSON parse error downstream, far from its cause.
