Skip to content

fix(java): drop one trailing null/undefined argument on this-calls - #65

Merged
kroitor merged 1 commit into
masterfrom
fix/java-trailing-null-varargs
Aug 9, 2026
Merged

fix(java): drop one trailing null/undefined argument on this-calls#65
kroitor merged 1 commit into
masterfrom
fix/java-trailing-null-varargs

Conversation

@kroitor

@kroitor kroitor commented Aug 9, 2026

Copy link
Copy Markdown
Member

Fixes the non-varargs call of varargs method with inexact argument type for last parameter javac warning class in ccxt's generated Java cores — 8 sites inventoried in ccxt/ccxt#29617 (PacificaCore ×2, pro/HyperliquidCore, BitfinexCore, prediction/LimitlessCore, prediction/HyperliquidCore ×2, ZebpayCore); the ninth (hand-written example) was fixed directly in ccxt/ccxt#29681.

Mechanism: the generated Java surface is uniformly (required..., Object... optionals) — 364 varargs signatures in BaseExchange.java — so a transpiled this.method(..., undefined) emits a bare trailing null that javac can't disambiguate between one-null-argument and null-varargs-array.

Fix: a Java-scoped printArgsForCallExpression override (slot was free — no prior java override) drops exactly one trailing NullKeyword/undefined argument when the receiver is this. Design notes:

  • Omission over casting: behaviorally identical by proof — both terminal varargs readers on the ccxt java side (Helpers.getArg: v == null || v.length <= index → def; SafeMethods.opt: dv == null || dv.length == 0 → null) treat a null array and an empty array the same, so f(x, null)f(x) at runtime today.
  • Single-drop, not greedy: bounds the blast radius; the pathological case (explicit undefined into a required trailing param) fails loudly at :lib:compileJava, never silently.
  • Interior nulls and non-this calls untouched; the implicit-API path is structurally unaffected (printWrappedUnknownThisProperty packs an explicit Object[] and never had the ambiguity).

Tests: 3 new cases (safe-family + parse + handleParam shapes, single-drop/interior-null preservation, non-this negative). Full java suite 100/100; cross-language suites python+cs 93/93, php+go 72/72 — zero regressions.

Follow-up on the ccxt side after the version bump: verify zero warnings in a clean :lib:compileJava, then consider -Werror on the category so the class can't regrow.

The generated Java surface is uniformly (required..., Object... optionals),
and a bare trailing null is ambiguous to javac ('non-varargs call of varargs
method with inexact argument type for last parameter') - 8 warning sites in
ccxt generated cores, inventoried in ccxt/ccxt#29617.

Omission is behaviorally identical to the current emission: both terminal
varargs readers on the ccxt java side (Helpers.getArg and SafeMethods.opt)
treat a null varargs array and an empty one the same. Interior nulls and
non-this calls are untouched; the implicit-API path is unaffected (it packs
arguments into an explicit Object[] via printWrappedUnknownThisProperty and
never had the ambiguity).
@kroitor kroitor self-assigned this Aug 9, 2026
@kroitor
kroitor merged commit 44285c6 into master Aug 9, 2026
1 check passed
@kroitor
kroitor deleted the fix/java-trailing-null-varargs branch August 9, 2026 14:52
kroitor pushed a commit that referenced this pull request Aug 9, 2026
The package entry points are the committed dist bundles and git-dependency
installs have no prepare hook, so #65
was inert downstream until this rebuild.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant