Commit 0a8f30ff authored by Eric Stevenson's avatar Eric Stevenson Committed by Commit Bot

jni_generator: Avoid external linkage for registration methods.

This CL moves the generated registration methods to an anonymous
namespace so that targets can have multiple generate_jni_registration()
dependencies that use @NativeMethods.

Currently this would cause a link time error due to duplicate symbols
being defined.

Bug: 929661
Change-Id: I240b8848bd37adfc02de6d70f40f81c2a2f057aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1749481Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686389}
parent 6d60d94c
......@@ -37,6 +37,8 @@ static const JNINativeMethod kMethods_org_chromium_base_natives_GEN_1JNIMAIN_DEX
};
namespace {
JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_base_natives_GEN_1JNIMAIN_DEX(JNIEnv* env) {
const int number_of_methods = base::size(kMethods_org_chromium_base_natives_GEN_1JNIMAIN_DEX);
......@@ -54,6 +56,8 @@ JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_base_natives_GEN_1JNIMA
return true;
}
} // namespace
// Step 4: Main dex and non-main dex registration functions.
......
......@@ -44,6 +44,8 @@ static const JNINativeMethod kMethods_org_chromium_base_natives_GEN_1JNI[] = {
};
namespace {
JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_base_natives_GEN_1JNI(JNIEnv* env) {
const int number_of_methods = base::size(kMethods_org_chromium_base_natives_GEN_1JNI);
......@@ -61,6 +63,8 @@ JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_base_natives_GEN_1JNI(J
return true;
}
} // namespace
static const JNINativeMethod kMethods_org_chromium_base_natives_GEN_1JNIMAIN_DEX[] = {
{ "test_foo_Foo_thisismaindex", "()V",
reinterpret_cast<void*>(Java_org_chromium_base_natives_GEN_1JNI_test_1foo_1Foo_1thisismaindex)
......@@ -68,6 +72,8 @@ static const JNINativeMethod kMethods_org_chromium_base_natives_GEN_1JNIMAIN_DEX
};
namespace {
JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_base_natives_GEN_1JNIMAIN_DEX(JNIEnv* env) {
const int number_of_methods = base::size(kMethods_org_chromium_base_natives_GEN_1JNIMAIN_DEX);
......@@ -85,6 +91,8 @@ JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_base_natives_GEN_1JNIMA
return true;
}
} // namespace
// Step 4: Main dex and non-main dex registration functions.
......
......@@ -57,6 +57,8 @@ static const JNINativeMethod kMethods_org_chromium_base_natives_GEN_1JNI[] = {
};
namespace {
JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_base_natives_GEN_1JNI(JNIEnv* env) {
const int number_of_methods = base::size(kMethods_org_chromium_base_natives_GEN_1JNI);
......@@ -74,6 +76,8 @@ JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_base_natives_GEN_1JNI(J
return true;
}
} // namespace
// Step 4: Main dex and non-main dex registration functions.
......
......@@ -123,6 +123,8 @@ static const JNINativeMethod kMethods_${ESCAPED_PROXY_CLASS}[] = {
${KMETHODS}
};
namespace {
JNI_REGISTRATION_EXPORT bool ${REGISTRATION_NAME}(JNIEnv* env) {
const int number_of_methods = base::size(kMethods_${ESCAPED_PROXY_CLASS});
......@@ -139,6 +141,8 @@ JNI_REGISTRATION_EXPORT bool ${REGISTRATION_NAME}(JNIEnv* env) {
return true;
}
} // namespace
""")
registration_call = string.Template("""\
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment