Skip to content

Support polymorphic type info for unsigned integer types - #459

Merged
k163377 merged 1 commit into
developfrom
claude/pensive-mayer-2kajyj
Oct 10, 2026
Merged

k163377 merged 1 commit into
developfrom
claude/pensive-mayer-2kajyj

Conversation

@k163377

@k163377 k163377 commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Port of FasterXML/jackson-module-kotlin#1228.

Problem

UByteSerializer / UShortSerializer / UIntSerializer / ULongSerializer extended StdSerializer directly and did not implement serializeWithType(). As a result, serializing an unsigned number failed with "Type id handling not implemented" whenever type information was required:

  • an Any property under default typing
  • a property annotated with @JsonTypeInfo (including collection contents)
  • a nullable unsigned property under DefaultTyping.EVERYTHING

For the same reason, schema generators were told the type is "any".

Changes

  • The four serializers now extend StdScalarSerializer, whose serializeWithType() writes the type id followed by the numeric value (e.g. ["kotlin.UInt",1]).
  • acceptJsonFormatVisitor() reports the integer format (INT / INT / LONG / BIG_INTEGER), since StdScalarSerializer assumes a string by default.
  • The deserializers already read the typed form and are unchanged.

Tests

Ported UnsignedNumbersTypeInfoTest and UnsignedNumbersJsonFormatVisitorTest into zPorted/test. Without the fix, 30 of the 55 unsigned-number tests fail; with it, ./gradlew lintKotlin test passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_0137oSJi6gZrpgW99q17VZVL


Generated by Claude Code

The UByte/UShort/UInt/ULong serializers extended StdSerializer directly
and did not implement `serializeWithType()`, so an unsigned number failed
to serialize whenever type information was required for it: an `Any`
property under default typing, a property annotated with `@JsonTypeInfo`
(including collection contents), or a nullable unsigned property under
`DefaultTyping.EVERYTHING`. Schema generators were also told the type is
"any".

Make the serializers extend StdScalarSerializer, whose `serializeWithType()`
writes the type id followed by the numeric value, and implement
`acceptJsonFormatVisitor()` with the integer format. The deserializers
already read the typed form and are left unchanged.

Ported from FasterXML/jackson-module-kotlin#1228.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137oSJi6gZrpgW99q17VZVL
@k163377
k163377 marked this pull request as ready for review October 10, 2026 05:31
@k163377
k163377 merged commit 8695e05 into develop Oct 10, 2026
22 checks passed
@k163377
k163377 deleted the claude/pensive-mayer-2kajyj branch October 10, 2026 05:31
@github-actions github-actions Bot mentioned this pull request Oct 10, 2026
8 tasks
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