Repository navigation
Refactor/improve object reader creator asm - #4021
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it?
Summary of your change
Please indicate you've done the following: