Skip to content

Commit

Permalink
jni_zero: Renaming JNI export macros and deleting use of BASE_EXPORT
Browse files Browse the repository at this point in the history
These 2 different export macros were confusingly named, so I renamed
them to more closely describe what they are intended to.

Also, I've broken the dep onto BASE_EXPORT.

Bug: 1377351
Change-Id: I59881bdbc10e4931a32a48b64ce2984cfd70136c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4953085
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Auto-Submit: Sam Maier <smaier@chromium.org>
Owners-Override: Andrew Grieve <agrieve@chromium.org>
Owners-Override: Sam Maier <smaier@chromium.org>
Commit-Queue: Sam Maier <smaier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1212226}
  • Loading branch information
Sam Maier authored and Chromium LUCI CQ committed Oct 19, 2023
1 parent 4879ca1 commit 2d208bd
Show file tree
Hide file tree
Showing 45 changed files with 488 additions and 462 deletions.
2 changes: 1 addition & 1 deletion base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,6 @@ component("base") {
deps += [
":base_jni",
":process_launcher_jni",
"//third_party/jni_zero:jni_helpers",
]
} # is_android || is_robolectric

Expand Down Expand Up @@ -3725,6 +3724,7 @@ test("base_unittests") {
deps += [
":base_java_unittest_support",
"//base/test:test_support_java",
"//third_party/jni_zero",
]
}

Expand Down
5 changes: 4 additions & 1 deletion base/android/linker/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ shared_library("chromium_android_linker") {
"linker_minimal_libcxx.cc",
]

deps = [ "//build:buildflag_header_h" ]
deps = [
"//build:buildflag_header_h",
"//third_party/jni_zero:jni_export",
]

# Export JNI symbols.
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
Expand Down
1 change: 1 addition & 0 deletions base/android/linker/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include_rules = [
# directory.
"-base",
"+base/android/linker",
"+third_party/jni_zero/jni_export.h",
]

# Allow using //base in unittests. These unittests are included in targets that
Expand Down
12 changes: 6 additions & 6 deletions base/android/linker/linker_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ bool NativeLibInfo::SharedMemoryFunctionsSupportedForTesting() {
return functions.IsWorking();
}

JNI_GENERATOR_EXPORT void
JNI_BOUNDARY_EXPORT void
Java_org_chromium_base_library_1loader_LinkerJni_nativeFindMemoryRegionAtRandomAddress(
JNIEnv* env,
jclass clazz,
Expand All @@ -722,7 +722,7 @@ Java_org_chromium_base_library_1loader_LinkerJni_nativeFindMemoryRegionAtRandomA
s_lib_info_fields.SetLoadInfo(env, lib_info_obj, address, size);
}

JNI_GENERATOR_EXPORT void
JNI_BOUNDARY_EXPORT void
Java_org_chromium_base_library_1loader_LinkerJni_nativeReserveMemoryForLibrary(
JNIEnv* env,
jclass clazz,
Expand All @@ -735,7 +735,7 @@ Java_org_chromium_base_library_1loader_LinkerJni_nativeReserveMemoryForLibrary(
s_lib_info_fields.SetLoadInfo(env, lib_info_obj, address, size);
}

JNI_GENERATOR_EXPORT jboolean
JNI_BOUNDARY_EXPORT jboolean
Java_org_chromium_base_library_1loader_LinkerJni_nativeFindRegionReservedByWebViewZygote(
JNIEnv* env,
jclass clazz,
Expand All @@ -749,7 +749,7 @@ Java_org_chromium_base_library_1loader_LinkerJni_nativeFindRegionReservedByWebVi
return true;
}

JNI_GENERATOR_EXPORT jboolean
JNI_BOUNDARY_EXPORT jboolean
Java_org_chromium_base_library_1loader_LinkerJni_nativeLoadLibrary(
JNIEnv* env,
jclass clazz,
Expand All @@ -770,7 +770,7 @@ Java_org_chromium_base_library_1loader_LinkerJni_nativeLoadLibrary(
return true;
}

JNI_GENERATOR_EXPORT jboolean
JNI_BOUNDARY_EXPORT jboolean
Java_org_chromium_base_library_1loader_LinkerJni_nativeUseRelros(
JNIEnv* env,
jclass clazz,
Expand All @@ -796,7 +796,7 @@ Java_org_chromium_base_library_1loader_LinkerJni_nativeUseRelros(
return true;
}

JNI_GENERATOR_EXPORT jint
JNI_BOUNDARY_EXPORT jint
Java_org_chromium_base_library_1loader_LinkerJni_nativeGetRelroSharingResult(
JNIEnv* env,
jclass clazz) {
Expand Down
11 changes: 1 addition & 10 deletions base/android/linker/linker_jni.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <stdlib.h>

#include "build/build_config.h"
#include "third_party/jni_zero/jni_export.h"

// Set this to 1 to enable debug traces to the Android log.
// Note that LOG() from "base/logging.h" cannot be used, since it is
Expand All @@ -43,16 +44,6 @@
#define PLOG_ERROR(FORMAT, ...) \
LOG_ERROR(FORMAT ": %s", ##__VA_ARGS__, strerror(errno))

#if defined(ARCH_CPU_X86)
// Dalvik JIT generated code doesn't guarantee 16-byte stack alignment on
// x86 - use force_align_arg_pointer to realign the stack at the JNI
// boundary. https://crbug.com/655248
#define JNI_GENERATOR_EXPORT \
extern "C" __attribute__((visibility("default"), force_align_arg_pointer))
#else
#define JNI_GENERATOR_EXPORT extern "C" __attribute__((visibility("default")))
#endif

#if defined(__arm__) && defined(__ARM_ARCH_7A__)
#define CURRENT_ABI "armeabi-v7a"
#elif defined(__arm__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ component_with_jni("cablev2_authenticator") {
deps = [
"//base",
"//chrome/android/features/cablev2_authenticator:native",
"//third_party/jni_zero",
]

# caBLE v2 authenticator native entrypoints belong in the partition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

extern "C" {
// This JNI registration method is found and called by module framework code.
JNI_GENERATOR_EXPORT bool JNI_OnLoad_cablev2_authenticator(JNIEnv* env) {
JNI_BOUNDARY_EXPORT bool JNI_OnLoad_cablev2_authenticator(JNIEnv* env) {
if (!cablev2_authenticator::RegisterNatives(env)) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions chrome/android/modules/stack_unwinder/internal/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ component_with_jni("stack_unwinder") {
"//base",
"//base:native_unwinder_android",
"//chrome/android/features/stack_unwinder/public:native",
"//third_party/jni_zero",
]

# stack unwinder native entrypoints belong in the partition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
extern "C" {
// This JNI registration method is found and called by module framework
// code.
JNI_GENERATOR_EXPORT bool JNI_OnLoad_stack_unwinder(JNIEnv* env) {
JNI_BOUNDARY_EXPORT bool JNI_OnLoad_stack_unwinder(JNIEnv* env) {
if (!stack_unwinder::RegisterNatives(env)) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions chrome/android/modules/test_dummy/internal/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ component_with_jni("test_dummy") {
deps = [
"//base",
"//chrome/browser/test_dummy/internal:native",
"//third_party/jni_zero",
]

# Test dummy native entrypoints belong in the partition.
Expand Down
2 changes: 1 addition & 1 deletion chrome/android/modules/test_dummy/internal/entrypoints.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

extern "C" {
// This JNI registration method is found and called by module framework code.
JNI_GENERATOR_EXPORT bool JNI_OnLoad_test_dummy(JNIEnv* env) {
JNI_BOUNDARY_EXPORT bool JNI_OnLoad_test_dummy(JNIEnv* env) {
if (!test_dummy::RegisterNatives(env)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ static_library("ui") {
"//device/vr/buildflags",
"//services/device/public/cpp/usb",
"//services/device/public/mojom:usb",
"//third_party/jni_zero:jni_helpers",
"//third_party/jni_zero",
"//ui/android",
"//url",
]
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/vr/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ component("vr_ui") {

if (is_android) {
sources += [ "jni_onload.cc" ]
deps += [ "//third_party/jni_zero" ]
}

if (use_command_buffer) {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/vr/jni_onload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
// register VR's native JNI methods. However, since VR's Android-specific native
// code still lives in the base module, VR's JNI registration is invoked
// manually. Therefore, this function does nothing.
JNI_GENERATOR_EXPORT bool JNI_OnLoad_vr(JNIEnv* env) {
JNI_BOUNDARY_EXPORT bool JNI_OnLoad_vr(JNIEnv* env) {
return true;
}
1 change: 1 addition & 0 deletions chromecast/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ component("cast_browser") {
deps = [
":common_apk_deps",
"//chromecast:cast_shell_lib_simple",
"//third_party/jni_zero",
]

cflags = [ "-fsymbol-partition=cast_browser_partition" ]
Expand Down
2 changes: 1 addition & 1 deletion chromecast/app/android/cast_browser_module_entrypoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

extern "C" {
// This JNI registration method is found and called by module framework code.
JNI_GENERATOR_EXPORT bool JNI_OnLoad_cast_browser(JNIEnv* env) {
JNI_BOUNDARY_EXPORT bool JNI_OnLoad_cast_browser(JNIEnv* env) {
content::Compositor::Initialize();
content::SetContentMainDelegate(new chromecast::shell::CastMainDelegate);
return true;
Expand Down
2 changes: 1 addition & 1 deletion components/permissions/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ source_set("permissions") {
"//components/prefs",
"//components/resources:android_resources",
"//components/security_state/core:core",
"//third_party/jni_zero:jni_helpers",
"//third_party/jni_zero",
"//ui/android",
"//ui/strings:ui_strings_grit",
]
Expand Down
2 changes: 1 addition & 1 deletion content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3251,7 +3251,7 @@ source_set("browser") {
"//third_party/blink/public/common:font_unique_name_table_proto",
"//third_party/blink/public/mojom:mojom_platform_blink",
"//third_party/icu",
"//third_party/jni_zero:jni_helpers",
"//third_party/jni_zero",
"//ui/accessibility:ax_assistant",
"//ui/accessibility:ax_base_android",
"//ui/accessibility/mojom",
Expand Down
2 changes: 1 addition & 1 deletion docs/android_dynamic_feature_modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ on all Chrome build variants, including Monochrome (unlike base module JNI).

extern "C" {
// This JNI registration method is found and called by module framework code.
JNI_GENERATOR_EXPORT bool JNI_OnLoad_foo(JNIEnv* env) {
JNI_BOUNDARY_EXPORT bool JNI_OnLoad_foo(JNIEnv* env) {
if (!foo::RegisterNatives(env)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/cardboard/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static_library("cardboard") {

deps = [
"//base",
"//third_party/jni_zero:jni_helpers",
"//third_party/jni_zero",
"//ui/gl",
]

Expand Down

0 comments on commit 2d208bd

Please sign in to comment.