Skip to content

Refactor/improve object reader creator asm - #4021

Merged
wenshao merged 4 commits into
mainfrom
refactor/improve-object-reader-creator-asm
Mar 12, 2026
Merged

wenshao merged 4 commits into
mainfrom
refactor/improve-object-reader-creator-asm

Conversation

@wenshao

@wenshao wenshao commented Mar 12, 2026

Copy link
Copy Markdown
Member

What this PR does / why we need it?

Summary of your change

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

wenshao and others added 4 commits March 12, 2026 09:00
…uplication

- Replace 12-case switch for super class selection with array lookup
- Extract buildHashCode32Map() to eliminate 4 duplicate TreeMap construction blocks
- Merge genMethodGetFieldReader/genMethodGetFieldReaderLCase into shared genMethodGetFieldReaderImpl
- Remove unused variables (get_ labels, fieldName strings) in field reader generation
- Cache fieldNameCharLengthMin/Max in ObjectReadContext to avoid recomputation in genMethodReadJSONBObject and genMethodReadObject
- Enrich exception diagnostics with field count, super class, and external class info
- Simplify always-true condition guarding genMethodGetFieldReader calls

Net reduction: ~150 lines of duplicated code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add private modifier to TYPE_OBJECT_READERS array and buildHashCode32Map method
- Fix fieldNameCharLengthMin initialization logic to match original behavior:
  use charLenMin == 0 guard (skips zero-length names) instead of i == 0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 tests covering all 6 refactored areas:
- TYPE_OBJECT_READERS array lookup: verify super class selection for 1/6/12/13 fields
- buildHashCode32Map: test >6 fields via readObject, readJSONBObject, getFieldReader
- genMethodGetFieldReaderImpl: test both case-sensitive and case-insensitive paths
- Removed unused variables: verify ≤6 fields branch correctness
- Cached fieldNameCharLengthMin/Max: test mixed lengths (2-10 chars), uniform lengths
- Comprehensive Client model: 20 fields with mixed types (UUID, BigDecimal, LocalDate,
  OffsetDateTime, enum, arrays, lists) across JSON, UTF-8, JSONB, SmartMatch paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ct creator

Add @DisabledIfSystemProperty for 3 tests that assert ASM-generated
class hierarchy (ObjectReader1~12), which differs under -Dfastjson2.creator=reflect.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wenshao
wenshao merged commit b3eb46c into main Mar 12, 2026
59 of 62 checks passed
@wenshao
wenshao deleted the refactor/improve-object-reader-creator-asm branch March 13, 2026 03:14
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