Fix NoSuchMethodException for Class.forName0 on Java 26#75
Open
arouel wants to merge 1 commit intotoolfactory:mainfrom
Open
Fix NoSuchMethodException for Class.forName0 on Java 26#75arouel wants to merge 1 commit intotoolfactory:mainfrom
NoSuchMethodException for Class.forName0 on Java 26#75arouel wants to merge 1 commit intotoolfactory:mainfrom
Conversation
In Java 26, the internal method Class.forName0 had its signature changed from: ```java Class.forName0(String, boolean, ClassLoader, Class) // 4 params - caller removed ``` to: ```java Class.forName0(String, boolean, ClassLoader) // 3 params ``` The `caller` parameter was removed because the caller-sensitive logic was refactored to resolve the classloader on the Java side before calling the native method. The existing `GetClassByNameFunction$ForJava7` tried to look up the old 4-parameter signature via `MethodHandles`, which threw `NoSuchMethodException` on Java 26. 1. `GetClassByNameFunction.java:99-121` - Added a new `ForJava26` inner class that: - Looks up `forName0` with the new 3-parameter signature `(String, boolean, ClassLoader)` - Ignores the caller parameter in `apply()` since it's no longer needed 2. `Info.java:34` - Added `26` to `CRITICAL_VERSIONS` so the ObjectProvider will discover and use `ForJava26` when running on JDK 26+.
NoSuchMethodException for Class.forName0 on Java 26+
NoSuchMethodException for Class.forName0 on Java 26+NoSuchMethodException for Class.forName0 on Java 26 (fixes #74)
NoSuchMethodException for Class.forName0 on Java 26 (fixes #74)NoSuchMethodException for Class.forName0 on Java 26
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.
Problem
In JDK 26, the caller-sensitive logic for
Class.forNamewas refactored so the classloader is resolved on the Java side before calling the native method. As a result,Class.forName0dropped its fourthClass<?> callerparameter. This breaksGetClassByNameFunction$ForJava7, which usesMethodHandlesto look up the old 4-parameter signature, causing aNoSuchMethodExceptionat runtime on JDK 26 (see issue #74).What
Adds a
ForJava26inner class that looks upforName0with the new 3-parameter signature(String, boolean, ClassLoader), adds26toCRITICAL_VERSIONS, and extends the CI matrix to cover JDK 25 and 26.