refactor/use method handles#819
Merged
Merged
Conversation
…ndle - Added MethodHandle support to MethodDescriptor with lazy initialization - Implemented genMethodHandle() using privileged blocks for setAccessible() - Changed RMIServant.invoke_method() to use MethodHandle.bindTo().invokeWithArguments() - Removed debug_name() helper, updated logging to use MethodDescriptor.toString() - Changed getReflectedMethod() visibility from public to package-private for security - Updated RMIStubHandler to pass MethodDescriptor instead of Method - Substantive lines added: 50, lines removed: 25 This targets the hottest path in RMI invocations, providing expected 2-5x performance improvement for remote method calls. Co-authored-by-AI: IBM Bob 1.0.4
- Added MethodHandle support for writeReplace, readResolve, and readObject methods - Implemented genReadObjectHandle() to create MethodHandle for readObject - Updated genWriteReplacer() to use MethodHandle instead of Method.invoke() - Updated genReadResolver() to use MethodHandle instead of Method.invoke() - Converted readObject invocations in buildReader() and buildCustomMarshalReaderWithReadObject() - Simplified exception handling for MethodHandle (throws Throwable directly) - Substantive lines added: 51, lines removed: 31 This improves performance for custom serialization during RMI-IIOP value marshaling. Co-authored-by-AI: IBM Bob 1.0.4
- Added MethodHandle support for writeObject method in ValueDescriptor - Implemented genWriteObjectHandle() and getWriteObjectHandle() accessor - Updated ObjectWriter.invokeWriteObject() to accept MethodHandle instead of Method - Simplified exception handling in invokeWriteObject() for MethodHandle - Updated buildCustomWriter() to pass MethodHandle via getWriteObjectHandle() - Substantive lines added: 24, lines removed: 14 This completes the custom serialization MethodHandle conversion, improving performance for writeObject during RMI-IIOP value marshaling. Co-authored-by-AI: IBM Bob 1.0.4
- Moved privileged setAccessible calls into gen*Handle methods - Removed unused writeObjectMethodRef and readObjectMethodRef lazy references - Removed genWriteObjectMethod() and genReadObjectMethod() methods - Made genWriteObjectHandle() and genReadObjectHandle() package-private for subclass overrides - Updated logic to check MethodHandle null-ness via getOptional*Handle() accessors - Added customMarshalledRef and chunkedRef as lazy references - Updated UncustomizableValueDescriptor and FVDUncustomizableValueDescriptor to override gen*Handle - Substantive lines added: 75, lines removed: 68 This refactoring consolidates the MethodHandle generation logic, eliminating redundant Method-based lazy references and ensuring all access control is handled within the MethodHandle generators. Co-authored-by-AI: IBM Bob 1.0.4
Convert Method.invoke() calls to MethodHandle.invoke() in IDLEntityDescriptor for better performance when calling IDL Helper methods (read, write, type). Changes: - Renamed findMethod() to findMethodHandle() to return MethodHandle directly - Updated genReader() to use MethodHandle for Helper.read() - Updated genWriter() to use MethodHandle for Helper.write() - Updated genTypeCode() to use MethodHandle for Helper.type() - Simplified exception handling with consistent pattern Co-authored-by-AI: IBM Bob 1.0.4 (Claude 3.5 Sonnet)
92a4739 to
d0bd406
Compare
Convert the remaining reflective defineClass invocation in org.apache.yoko.rmi.util.stub.Util from Method.invoke() to MethodHandle.invoke(). Changes: - store ClassLoader.defineClass as a MethodHandle - use PrivilegedActions.makeAccessible() before unreflect() - simplify invoke() exception handling for MethodHandle semantics Co-authored-by-AI: IBM Bob 1.0.4
…Accessible - Simplified ClassBaseDescriptor.findField() to use getDeclaredField() and makeAccessible() - Simplified MethodDescriptor.genMethodHandle() to use getDeclaredMethod() and makeAccessible() - Simplified FieldDescriptor field copy creation to use getDeclaredField() and makeAccessible() - Removed manual setAccessible(true) calls in favor of PrivilegedActions.makeAccessible() - Lines added: 21, lines removed: 23 Co-authored-by-AI: IBM Bob 1.0.4
- Removed doPrivileged(exAction(...)) wrapper from CorbaObjectWriter instantiation in writeValue() - Removed doPrivileged(exAction(...)) wrapper from CorbaObjectReader instantiation in makeCorbaObjectReader() - Removed associated PrivilegedActionException catch blocks - Both constructors only perform simple field assignments without security-sensitive operations - Lines added: 2, lines removed: 7 Co-authored-by-AI: IBM Bob 1.0.4
Convert Method.invoke() to MethodHandle.invoke() for IDL Helper narrow() calls in PortableRemoteObjectImpl with ClassValue-based caching. Changes: - Added HELPER_NARROW_CACHE using ClassValue<MethodHandle>, mapping from helper class to its "narrow" method - Updated narrowIDL() to use cached MethodHandle instead of Method.invoke() - Simplified exception handling with consistent pattern - Updated MultiAddressUrlTest to remove InvocationTargetException from expected causal chains, as MethodHandle.invoke() does not add this wrapper layer (unlike the old Method.invoke() approach) - Fixed exception handling in StubWriteReplaceMethodHolder to properly unwrap PrivilegedActionException - Lines added: 29, lines removed: 13 Performance: ClassValue provides thread-safe per-class caching without locks Co-authored-by: Joe Chacko <chackoj@uk.ibm.com> Co-authored-by-AI: IBM Bob 1.0.4
d0bd406 to
9e7fedb
Compare
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 Java 7: Replace method invocation via reflection with use of MethodHandles #807