Skip to content

Remove the reflection warning in LocalDateTime -> offset-date-time - #213

Merged
henryw374 merged 1 commit into
juxt:masterfrom
pyze:fix/reflection-get-offset
Oct 25, 2026
Merged

henryw374 merged 1 commit into
juxt:masterfrom
pyze:fix/reflection-get-offset

Conversation

@markaddleman

Copy link
Copy Markdown
Contributor

Compiling tick.core on the JVM with *warn-on-reflection* set prints one warning:

Reflection warning, tick/core.cljc:230:29 - call to method getOffset can't be resolved (target class is unknown).

The call is in the offset-date-time conversion for LocalDateTime. cljc.java-time.zone-id/get-rules has no return tag, so the compiler cannot find ZoneRules.getOffset and emits a reflective call.

Why it matters: a GraalVM native image cannot make a reflective call unless the class is registered in reflection config. Programs that build a native image usually treat every reflection warning as a build failure, so this one warning in tick blocks them, even when they never call this function.

The fix: one ^java.time.zone.ZoneRules type hint on the get-rules form. The ClojureScript branch does not change.

The test: test/tick/reflection_test.clj reloads tick.core with *warn-on-reflection* bound to true and asserts that no reflection warning is printed. It fails without the hint and passes with it.

Results on this branch: ./bin/kaocha :clj gives 68 tests, 724 assertions, 0 failures. and make test-cljs-shadow gives 60 tests, 695 assertions, 0 failures.

The branch starts at the 1.0.1 tag. src/ has no other change between 1.0.1 and master, so it merges cleanly.

tick.core printed one reflection warning on the JVM:

  Reflection warning, tick/core.cljc:230:29 - call to method getOffset
  can't be resolved (target class is unknown).

cljc.java-time.zone-id/get-rules has no return tag, so the compiler cannot
resolve the .getOffset call. A ZoneRules hint on that form resolves it.

A new test, tick.reflection-test, reloads tick.core with
*warn-on-reflection* bound to true and asserts that no reflection warning
is printed.
@henryw374
henryw374 merged commit ce28430 into juxt:master Oct 25, 2026
1 check passed
@henryw374

Copy link
Copy Markdown
Collaborator

very clear PR. thanks

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.

2 participants