Skip to content

Commit b69e79d

Browse files
authored
[refactor](jni)refactor jni util for safe jni call (#56763)
### What problem does this PR solve? Problem Summary: This PR significantly refactors the JNI util class. It introduces a safer way to operate JNI, including automatic reference deletion and exception checking...
1 parent f4a3361 commit b69e79d

22 files changed

+2626
-1406
lines changed

be/src/agent/task_worker_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2399,7 +2399,7 @@ void clean_udf_cache_callback(const TAgentTaskRequest& req) {
23992399
if (doris::config::enable_java_support) {
24002400
LOG(INFO) << "clean udf cache start: " << req.clean_udf_cache_req.function_signature;
24012401
static_cast<void>(
2402-
JniUtil::clean_udf_class_load_cache(req.clean_udf_cache_req.function_signature));
2402+
Jni::Util::clean_udf_class_load_cache(req.clean_udf_cache_req.function_signature));
24032403
LOG(INFO) << "clean udf cache finish: " << req.clean_udf_cache_req.function_signature;
24042404
}
24052405
}

be/src/io/fs/benchmark/benchmark_factory.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class MultiBenchmark {
104104
Status status = Status::OK();
105105
if (doris::config::enable_java_support) {
106106
// Init jni
107-
status = doris::JniUtil::Init();
107+
status = doris::Jni::Util::Init();
108108
if (!status.ok()) {
109109
LOG(WARNING) << "Failed to initialize JNI: " << status;
110110
exit(1);

be/src/io/fs/hdfs_file_writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class HdfsWriteMemUsageRecorder {
128128
private:
129129
// clang-format off
130130
size_t max_jvm_heap_size() const {
131-
return JniUtil::get_max_jni_heap_memory_size();
131+
return Jni::Util::get_max_jni_heap_memory_size();
132132
}
133133
// clang-format on
134134
[[maybe_unused]] std::size_t cur_memory_comsuption {0};

be/src/service/doris_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ int main(int argc, char** argv) {
490490
Status status = Status::OK();
491491
if (doris::config::enable_java_support) {
492492
// Init jni
493-
status = doris::JniUtil::Init();
493+
status = doris::Jni::Util::Init();
494494
if (!status.ok()) {
495495
LOG(WARNING) << "Failed to initialize JNI: " << status;
496496
exit(1);

be/src/util/doris_metrics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ void DorisMetrics::initialize(bool init_system_metrics, const std::set<std::stri
441441
}
442442
}
443443

444-
void DorisMetrics::init_jvm_metrics(JNIEnv* env) {
445-
_jvm_metrics.reset(new JvmMetrics(&_metric_registry, env));
444+
void DorisMetrics::init_jvm_metrics() {
445+
_jvm_metrics.reset(new JvmMetrics(&_metric_registry));
446446
}
447447

448448
void DorisMetrics::_update() {

be/src/util/doris_metrics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class DorisMetrics {
288288
SystemMetrics* system_metrics() { return _system_metrics.get(); }
289289
MetricEntity* server_entity() { return _server_metric_entity.get(); }
290290
JvmMetrics* jvm_metrics() { return _jvm_metrics.get(); }
291-
void init_jvm_metrics(JNIEnv* env);
291+
void init_jvm_metrics();
292292

293293
private:
294294
// Don't allow constructor

0 commit comments

Comments
 (0)