mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Use JavaScriptModuleRegistry.getJSModuleName()
Summary: It turns out that in release builds, proguard is doing something weird with inner classes, so that getSimpleName() is actually returning "OuterClass$InnerClass" in some cases. We have logic to handle this case already in JavaScriptModuleRegistry, so I'm moving that out to a static method that I can access in bridgeless mode. Also adding tests for it. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D19701703 fbshipit-source-id: 625737bfb50ca8ba2bd26034e2a74c682783ba8a
This commit is contained in:
committed by
Facebook Github Bot
parent
014bc95135
commit
73427561f7
@@ -25,8 +25,7 @@ rn_android_library(
|
||||
rn_robolectric_test(
|
||||
name = "bridge",
|
||||
srcs = glob(STANDARD_TEST_SRCS),
|
||||
# Please change the contact to the oncall of your team
|
||||
contacts = ["oncall+fbandroid_sheriff@xmail.facebook.com"],
|
||||
contacts = ["oncall+react_native@xmail.facebook.com"],
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.bridge;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/** Tests for {@link JavaScriptModuleRegistry} */
|
||||
public class JavaScriptModuleRegistryTest {
|
||||
|
||||
private interface TestJavaScriptModule extends JavaScriptModule {
|
||||
void doSomething();
|
||||
}
|
||||
|
||||
private interface OuterClass$NestedInnerClass extends JavaScriptModule {
|
||||
void doSomething();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJSModuleName() {
|
||||
String name = JavaScriptModuleRegistry.getJSModuleName(TestJavaScriptModule.class);
|
||||
Assert.assertEquals("TestJavaScriptModule", name);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJSModuleName_stripOuterClass() {
|
||||
String name = JavaScriptModuleRegistry.getJSModuleName(OuterClass$NestedInnerClass.class);
|
||||
Assert.assertEquals("NestedInnerClass", name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user