refactor/use method handles for simple constructors#822
Merged
joe-chacko merged 5 commits intoJun 24, 2026
Merged
Conversation
bc5d089 to
af42bee
Compare
- Replaced stub_map with ClassValue<Constructor<? extends Stub>> in RMIState - Replaced static_stub_map with ClassValue<Optional<Constructor<? extends Stub>>> - Moved stub constructor computation logic from PortableRemoteObjectImpl to RMIState.computeRMIStubConstructor() - Simplified PortableRemoteObjectImpl.getRMIStubClassConstructor() to delegate to ClassValue - Refactored stub class creation to use Optional for cleaner null handling - Removed NoDeleteSynchronizedMap.java (no longer needed) - Removed unused codebase parameter from getStaticStub() and related methods Benefits: - Thread-safe caching without explicit synchronization via ClassValue - Better performance through ClassValue's optimized per-class caching - Cleaner separation of concerns with stub construction centralized in RMIState - More idiomatic code using Optional for null handling - Lines added: 81, lines removed: 190 Co-authored-by-AI: IBM Bob 1.0.4
- Converted MethodRef from mutable to immutable class - Replaced direct field access with lazy-initialized references using LazyReference - Changed getParameterTypes() and getExceptionTypes() to return unmodifiable Lists instead of arrays - Updated BCELClassBuilder to work with List-based API instead of array-based API - Removed unused import of java.util.logging.Level - Fixed escaped quote in license header - Substantive lines added: 45, lines removed: 89 Co-authored-by-AI: IBM Bob 1.0.4
…reation - Replaced reflection-based Constructor.newInstance() with MethodHandle.invoke() - Introduced Supplier<Stub> pattern throughout RMIState for lazy stub instantiation - Deduplicated genStubSupplier() methods by creating overloaded version taking Constructor - Added NULL_STUB_SUPPLIER constant to replace repeated () -> null lambdas - Simplified stub creation logic in PortableRemoteObjectImpl using Optional - Renamed tie_map to tieMap for consistency - Substantive lines added: 82, lines removed: 108 Co-authored-by-AI: IBM Bob 1.0.4
…ntiation - Introduced NULL_SERIALIZABLE_SUPPLIER constant to eliminate duplicate lambda expressions - Made genBlankInstanceSupplier() package-private to allow subclass overrides - Made createBlankInstance() private to enforce proper encapsulation - Refactored Externalizable instantiation to use MethodHandles for better performance - Kept Constructor.newInstance() for Serializable types (required by ReflectionFactory) - Updated FVDUncustomizableValueDescriptor to override genBlankInstanceSupplier() - Updated UncustomizableValueDescriptor to override genBlankInstanceSupplier() - Added explanatory comments for why Serializable types cannot use MethodHandles - Simplified exception handling in MethodHandle supplier using multi-catch - Lines added: 60, lines removed: 58 Co-authored-by-AI: IBM Bob 1.0.4
- Introduce InstanceFactory utility class with cached MethodHandle-based instantiation - Replace reflection-based Constructor.newInstance() calls with MethodHandles for better performance - Add CannotInstantiateException as unchecked wrapper for instantiation failures - Update YokoInputStream to use createNoArgsInstance for stub creation - Update PluginManager to use createNoArgsInstance for plugin initialization - Update ValueFactoryManager to use createNoArgsInstance and simplify error handling - Update ValueReader to use createNoArgsInstance for value and helper instantiation - Update ValueWriter to use createNoArgsInstance for helper instantiation - Update ORB_impl to use createNoArgsInstance for ORB initializer creation - Update iiop plugin to use createNoArgsInstance for connection helper creation - Update SecurityContext to use createNoArgsInstance for delegate creation - Refactor RepIds.toClass() to simplify control flow and reduce nesting - Substantive lines added: 149, lines removed: 84 Co-authored-by-AI: IBM Bob 1.0.4
af42bee to
203071e
Compare
joe-chacko
approved these changes
Jun 24, 2026
joe-chacko
left a comment
Member
There was a problem hiding this comment.
This is good work. Let's merge it and see what happens.
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.
Fixes #807