From 375350506afbd6bf87aea5aff203bd8456857c99 Mon Sep 17 00:00:00 2001 From: Samuel Freilich Date: Mon, 4 May 2026 09:48:14 -0700 Subject: [PATCH] Internal change PiperOrigin-RevId: 910085020 --- ink/brush/internal/jni/brush_behavior_jni.cc | 7 ++++++- ink/brush/internal/jni/brush_tip_jni.cc | 8 +++++++- ink/jni/BUILD.bazel | 8 +++++++- ink/kmp/BUILD.bazel | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ink/brush/internal/jni/brush_behavior_jni.cc b/ink/brush/internal/jni/brush_behavior_jni.cc index ad79851a..761b107e 100644 --- a/ink/brush/internal/jni/brush_behavior_jni.cc +++ b/ink/brush/internal/jni/brush_behavior_jni.cc @@ -45,8 +45,13 @@ JNI_METHOD(brush, BrushBehaviorNative, jlong, createFromOrderedNodes) jlong* node_pointers = env->GetLongArrayElements(node_native_pointer_array, nullptr); ABSL_CHECK(node_pointers != nullptr); + // Both `jlong` and `int64_t` are required to be 64-bit integers which JNI and + // Kotlin-cinterop respectively both map to Kotlin `Long`. However, on MacOS + // they represent two distinct (though equivalent) types, `jlong` is `long` + // but `int64_t` is `long long`. + static_assert(sizeof(jlong) == sizeof(int64_t)); int64_t result = BrushBehaviorNative_createFromOrderedNodes( - env, node_pointers, num_nodes, + env, reinterpret_cast(node_pointers), num_nodes, JStringToStdString(env, developer_comment).c_str(), &ThrowExceptionFromStatusCallback); env->ReleaseLongArrayElements( diff --git a/ink/brush/internal/jni/brush_tip_jni.cc b/ink/brush/internal/jni/brush_tip_jni.cc index e857157c..0754a068 100644 --- a/ink/brush/internal/jni/brush_tip_jni.cc +++ b/ink/brush/internal/jni/brush_tip_jni.cc @@ -36,10 +36,16 @@ JNI_METHOD(brush, BrushTipNative, jlong, create) env->GetArrayLength(behavior_native_pointers_array); jlong* behavior_pointers = env->GetLongArrayElements(behavior_native_pointers_array, nullptr); + // Both `jlong` and `int64_t` are required to be 64-bit integers which JNI and + // Kotlin-cinterop respectively both map to Kotlin `Long`. However, on MacOS + // they represent two distinct (though equivalent) types, `jlong` is `long` + // but `int64_t` is `long long`. + static_assert(sizeof(jlong) == sizeof(int64_t)); int64_t result = BrushTipNative_create( env, scale_x, scale_y, corner_rounding, slant_degrees, pinch, rotation_degrees, particle_gap_distance_scale, - particle_gap_duration_millis, behavior_pointers, num_behaviors, + particle_gap_duration_millis, + reinterpret_cast(behavior_pointers), num_behaviors, &ThrowExceptionFromStatusCallback); env->ReleaseLongArrayElements(behavior_native_pointers_array, behavior_pointers, JNI_ABORT); diff --git a/ink/jni/BUILD.bazel b/ink/jni/BUILD.bazel index baa04c74..474dcdb3 100644 --- a/ink/jni/BUILD.bazel +++ b/ink/jni/BUILD.bazel @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@bazel_skylib//rules:build_test.bzl", "build_test") load("@rules_cc//cc:cc_binary.bzl", "cc_binary") load("@rules_cc//cc:cc_library.bzl", "cc_library") @@ -27,7 +28,7 @@ cc_binary( ], features = ["-legacy_whole_archive"], linkopts = select({ - "@platforms//os:macos": [ + "@platforms//os:ios": [ "-Wl,-exported_symbols_list,$(location :exported_symbols.txt)", ], "//conditions:default": [ @@ -42,6 +43,11 @@ cc_binary( ], ) +build_test( + name = "libink_so_build_test", + targets = [":libink.so"], +) + cc_library( name = "android_no_proto_jni", tags = ["keep_dep"], diff --git a/ink/kmp/BUILD.bazel b/ink/kmp/BUILD.bazel index f0f744de..4f992cbb 100644 --- a/ink/kmp/BUILD.bazel +++ b/ink/kmp/BUILD.bazel @@ -24,6 +24,7 @@ package( cc_static_library( name = "ink", deps = [ + "//ink/brush/internal/jni:cinterop", "//ink/geometry/internal/jni:cinterop", "//ink/jni/internal:cinterop", ],