yaooqinn opened a new pull request, #13774:
URL: https://github.com/apache/gluten/pull/13774
## What changes are proposed in this pull request?
The JNI specification requires `FindClass` to take a binary class name such
as
`java/lang/String`. Several Gluten native call sites pass a field descriptor
instead,
such as `Lorg/apache/gluten/runtime/RuntimeAware;`.
HotSpot accepts the descriptor form today, but under `-Xcheck:jni` it warns:
```
WARNING in native method: JNI FindClass received a bad class descriptor
"Lp/Aware;".
A correct class descriptor has no leading "L" or trailing ";".
Incorrect descriptors will not be accepted in future releases.
```
A JVM that follows the specification strictly returns null for the
descriptor form, and
Gluten then fails during `JNI_OnLoad` (for example, `Unable to find method
rtHandle`).
This PR changes every such call site in `cpp/core`, `cpp/velox` and
`cpp/bolt` (13 files)
to the binary-name form. Where a string served as both a class name and a
static field
signature (`UDFResolver$`, used for `FindClass` and for the `MODULE$`
field), it is split
into a class name constant and a signature constant, because
`GetStaticFieldID` does
require the descriptor form.
No behavior change on HotSpot. The ClickHouse backend (`cpp-ch`) has the
same pattern
at about 13 sites; it is left for a separate `[CH]` change to keep this one
reviewable.
## How was this patch tested?
- New `cpp/core/tests/JniClassNameTest.cc`: a fake `JNIEnv` whose
`FindClass` rejects the
descriptor form, as the specification allows. It initializes
`JniCommonState` and
`JniErrorState` and asserts that no descriptor reached `FindClass`.
Without the fix both
tests fail (`descriptor passed to FindClass:
Lorg/apache/gluten/runtime/RuntimeAware;`);
with the fix both pass.
- Full native build (Velox backend) with `--build_tests=ON` and `ctest`:
`100% tests passed, 0 tests failed out of 5773`.
- clang-format 15 on all changed files.
- An independent read-only review checked every class lookup in `cpp/core`,
`cpp/velox`
and `cpp/bolt`, the descriptor-only sites (`GetStaticFieldID`, method
signatures,
`[B`), and the fake `JNIEnv` against the calls made by both `initialize`
functions. It
found no defect; its suggestion, a `static_assert` that the fake env is
standard-layout
(needed by `offsetof`), is included.
## Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]