From fd627e16e97b1d3dbbb4c964768062f1f5da96dd Mon Sep 17 00:00:00 2001 From: Radek Hubner Date: Mon, 30 Oct 2023 13:22:18 +0400 Subject: [PATCH] Fix API compatibility. Proper type declaration in C++. --- java/rocksjni/options.cc | 8 ++++---- java/src/test/java/org/rocksdb/OptionsTest.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/java/rocksjni/options.cc b/java/rocksjni/options.cc index 36db32c48c0a..dbcf097e26cc 100644 --- a/java/rocksjni/options.cc +++ b/java/rocksjni/options.cc @@ -3936,7 +3936,7 @@ jint Java_org_rocksdb_Options_memtableMaxRangeDeletions(JNIEnv*, jobject, jlongArray Java_org_rocksdb_Options_tablePropertiesCollectorFactory( JNIEnv* env, jclass, jlong jhandle) { auto* opt = reinterpret_cast(jhandle); - const auto size = opt->table_properties_collector_factories.size(); + const size_t size = opt->table_properties_collector_factories.size(); jlongArray retVal = env->NewLongArray(static_cast(size)); if (retVal == nullptr) { // exception thrown: OutOfMemoryError @@ -3948,7 +3948,7 @@ jlongArray Java_org_rocksdb_Options_tablePropertiesCollectorFactory( return nullptr; } - for (int i = 0; i < size; i++) { + for (size_t i = 0; i < size; i++) { auto* wrapper = new TablePropertiesCollectorFactoriesJniWrapper(); wrapper->table_properties_collector_factories = opt->table_properties_collector_factories[i]; @@ -3966,7 +3966,7 @@ jlongArray Java_org_rocksdb_Options_tablePropertiesCollectorFactory( void Java_org_rocksdb_Options_setTablePropertiesCollectorFactory( JNIEnv* env, jclass, jlong jhandle, jlongArray j_factory_handlers) { auto* opt = reinterpret_cast(jhandle); - const auto size = env->GetArrayLength(j_factory_handlers); + const jsize size = env->GetArrayLength(j_factory_handlers); jlong* buf = env->GetLongArrayElements(j_factory_handlers, NULL); if (buf == nullptr) { @@ -3975,7 +3975,7 @@ void Java_org_rocksdb_Options_setTablePropertiesCollectorFactory( } opt->table_properties_collector_factories.clear(); - for (int i = 0; i < size; i++) { + for (jsize i = 0; i < size; i++) { auto* wrapper = reinterpret_cast(buf[i]); opt->table_properties_collector_factories.emplace_back( diff --git a/java/src/test/java/org/rocksdb/OptionsTest.java b/java/src/test/java/org/rocksdb/OptionsTest.java index 1d310ab24beb..5de42a13e758 100644 --- a/java/src/test/java/org/rocksdb/OptionsTest.java +++ b/java/src/test/java/org/rocksdb/OptionsTest.java @@ -1501,7 +1501,7 @@ public void tablePropertiesCollectorFactory() { try (final Options options = new Options()) { try (TablePropertiesCollectorFactory collectorFactory = TablePropertiesCollectorFactory.NewCompactOnDeletionCollectorFactory(10, 10, 1.0)) { - List factories = List.of(collectorFactory); + List factories = Arrays.asList(collectorFactory); options.setTablePropertiesCollectorFactory(factories); } List factories = options.tablePropertiesCollectorFactory();