Fix Class.getMethod() to reject non-public interface methods - #23384
Merged
babsingh merged 1 commit intoMar 6, 2026
Merged
Conversation
tomal-majumder
force-pushed
the
fix-getMethod-issue-22448
branch
from
February 20, 2026 23:28
bc81b56 to
a9b77e9
Compare
babsingh
reviewed
Feb 23, 2026
Contributor
|
Also, the commit guidelines are not followed: https://github.com/eclipse-openj9/openj9/blob/master/CONTRIBUTING.md#commit-guidelines -> |
tomal-majumder
force-pushed
the
fix-getMethod-issue-22448
branch
3 times, most recently
from
February 27, 2026 01:11
d323ab2 to
39ac334
Compare
tomal-majumder
commented
Feb 27, 2026
babsingh
reviewed
Feb 27, 2026
tomal-majumder
force-pushed
the
fix-getMethod-issue-22448
branch
from
February 27, 2026 23:22
39ac334 to
fc97f64
Compare
babsingh
reviewed
Mar 2, 2026
Contributor
|
tomal-majumder
force-pushed
the
fix-getMethod-issue-22448
branch
3 times, most recently
from
March 5, 2026 22:57
e302ec4 to
616ee59
Compare
tomal-majumder
marked this pull request as ready for review
March 5, 2026 23:14
Contributor
|
jenkins test sanity amac jdk21 |
Contributor
|
jenkins test sanity alinux64 jdk11 |
keithc-ca
reviewed
Mar 6, 2026
Contributor
|
Documenting PR build links so only minimal testing is required for the requested formatting changes: |
tomal-majumder
force-pushed
the
fix-getMethod-issue-22448
branch
from
March 6, 2026 18:48
616ee59 to
ea89a02
Compare
Update getMethodHelper() to properly throw NoSuchMethodException when Class.getMethod() is called on non-public interface methods. Added test coverage in Java9andUp/GetMethodTests: - Private static methods in interfaces throw NoSuchMethodException - Private non-static methods in interfaces throw NoSuchMethodException - Public methods successfully returns a Method Fixes: eclipse-openj9#22448 Signed-off-by: Tomal Majumder <Tomal.Majumder@ibm.com>
tomal-majumder
force-pushed
the
fix-getMethod-issue-22448
branch
from
March 6, 2026 18:53
ea89a02 to
542e5da
Compare
keithc-ca
approved these changes
Mar 6, 2026
Contributor
|
jenkins test sanity.functional amac jdk17 |
babsingh
approved these changes
Mar 6, 2026
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.
Fix Class.getMethod() to throw NoSuchMethodException for non-public interface methods
Problem
Class.getMethod()must return only public methods or throwNoSuchMethodExceptionas per Java specification. Previously, when invoked on interface types with non-public methods (private static or non-static), the method incorrectly returnednullinstead of throwing the required exception.Root Cause
The issue was in the
initialResultShouldBeReplacedcode path ingetMethodHelper(). WhenpublicOnlywas true but the initial result was a non-public method, and no public alternatives were found, the method returnednullinstead of callingthrowExceptionOrReturnNull().Test cases added in
Java9andUp/GetMethodTestscovering cases of Class.getMethod() call for both public and non-public interface methods.Test Results:
Local builds and Jenkins grinder tests were executed for aarch64 using JDK 11 and JDK 25.
jdk_lang_j9_0andjdk_lang_j9_1. JDK25 fails onjava/util/StringJoiner/StringJoinerTestThe sanity.openjdk failures are already tracked issues:
jdk_lang_j9_0andjdk_lang_j9_1failures observed across multiple Java levels (JDK 11, 17) and platforms (linux64, x86-64_mac): jdk_lang_j9_0 and jdk_lang_j9_1, Unexpected provider count. Expected: 13. Actual: 12 #23389StringJoinerTest OutOfMemoryError: Java heap spacehas recently been seen in openjdk25 on ppc64le_linux: OpenJDK java/util/StringJoiner/StringJoinerTest OutOfMemoryError: Java heap space #18708 (comment)These failures are outside this change and appear to be existing issues.
Fixes: #22448