Skip to content

refactor: use empty array singletons#799

Open
ngmr wants to merge 2 commits into
OpenLiberty:mainfrom
ngmr:refactor/use-empty-array-singletons
Open

refactor: use empty array singletons#799
ngmr wants to merge 2 commits into
OpenLiberty:mainfrom
ngmr:refactor/use-empty-array-singletons

Conversation

@ngmr
Copy link
Copy Markdown
Member

@ngmr ngmr commented Jun 2, 2026

  • Introduced Arrays.emptyArray() utility method with thread-safe caching
    using ConcurrentHashMap for system classes and SoftReference for custom classes
  • Replaced manual empty array allocations (new Type[0]) across 64 files
    in yoko-core, yoko-rmi-impl, testify-iiop, and yoko-verify
  • Added comprehensive test suite for Arrays.emptyArray() with 18 tests
    covering thread safety, caching behavior, and custom class handling
  • Substantive lines added: 672, lines removed: 154

Co-authored-by-AI: IBM Bob 1.0.4

@ngmr ngmr self-assigned this Jun 2, 2026
@ngmr ngmr requested a review from joe-chacko June 2, 2026 22:54
@ngmr ngmr force-pushed the refactor/use-empty-array-singletons branch 5 times, most recently from 26405cf to 63d6c0e Compare June 3, 2026 00:21
ngmr and others added 2 commits June 3, 2026 15:51
- Introduced Arrays.emptyArray() utility method with thread-safe caching using ClassValue
- Replaced manual empty array allocations (new Type[0]) across 64 files
  in yoko-core, yoko-rmi-impl, testify-iiop, and yoko-verify
- Added comprehensive test suite for Arrays.emptyArray() with 16 tests
  covering thread safety, caching behavior, and ClassValue semantics
- Added documentation explaining GC safety of ClassValue-based caching
- Substantive lines added: 672, lines removed: 154

Co-authored-by-AI: IBM Bob 1.0.4 (Claude 3.5 Sonnet)
- Add NO_STRINGS constant to Arrays utility class for common empty String array usage
- Replace emptyArray(String.class) calls with NO_STRINGS constant across codebase
- Update Arrays.emptyArray() to use ClassValue<Object> instead of ClassValue<Object[]>
- Add assertion to prevent primitive types in emptyArray() method
- Update ArraysTest to verify NO_STRINGS constant behavior
- Refactor 21 files across testify-iiop, yoko-core, yoko-rmi-impl, yoko-util, and yoko-verify modules
- Lines added: 87, lines removed: 68 (ignoring whitespace)

Co-authored-by: Joe Chacko <chackoj@uk.ibm.com>
Co-authored-by-AI: IBM Bob 1.0.4
@ngmr ngmr force-pushed the refactor/use-empty-array-singletons branch from 63d6c0e to 323e8ef Compare June 3, 2026 23:23
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