Fix findPubliclyAccessibleMethod to search interfaces for accessible methods#4287
Merged
Fix findPubliclyAccessibleMethod to search interfaces for accessible methods#4287
Conversation
…methods (#4278) The findPubliclyAccessibleMethod algorithm only traversed superclasses when looking for a publicly accessible method. This caused InaccessibleObjectException on Java 16+ for non-public classes that implement public interfaces (e.g., TreeMap.Entry implementing Map.Entry), because the method was never found through the public interface and the fallback to setAccessible fails on JDK internal classes. Now the algorithm also checks interfaces implemented by each class in the hierarchy, finding methods declared on public interfaces like Map.Entry. https://claude.ai/code/session_0172bEhuTAQF3gcvxip6wz5K
bbakerman
reviewed
Mar 4, 2026
| } | ||
| } | ||
| // Also search super-interfaces of non-public interfaces | ||
| Method method = findMethodOnPublicInterfaces(cacheKey, iface.getInterfaces(), methodName, dfeInUse, allowStaticMethods); |
Member
There was a problem hiding this comment.
You allowing interfaces implementing interfaces - fair enough - but there is not tests for that
I think you need to create the complicated structure that tests this
Contributor
Test ReportTest Results
Code Coverage (Java 25)
Changed Class Coverage (1 class)
|
Test that findMethodOnPublicInterfaces correctly traverses package-private intermediate interfaces to find methods declared on public super-interfaces. Covers linear chain (pkg-private -> public grandparent) and diamond inheritance patterns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bbakerman
approved these changes
Mar 7, 2026
3 tasks
4 tasks
Cover the dfeInUse path and NoSuchMethodException fallthrough in findMethodOnPublicInterfaces. Raises PropertyFetchingImpl line coverage from 86.1% to 88.2%, above the 87.8% baseline. 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.
Summary
PropertyDataFetcherfails to fetch properties on non-public classes (e.g.,TreeMap.Entry) that implement public interfaces (e.g.,Map.Entry) on Java 16+ wheresetAccessibleis restricted for JDK internal classesfindMethodOnPublicInterfacesmethod that recursively searches public interfaces implemented by a class when the class itself is not publicly accessiblePropertyDataFetchercan fetchkeyandvaluefromTreeMap.Entryvia the publicMap.EntryinterfaceTest plan
valueandkeyproperties fromTreeMap.EntryinstancesPropertyDataFetcherandSingletonPropertyDataFetcherhttps://claude.ai/code/session_01KSM9EgschAaxJVFeqM1enw