File tree Expand file tree Collapse file tree
packages/react-native/ReactAndroid/src
main/java/com/facebook/hermes/reactexecutor
test/java/com/facebook/hermes/reactexecutor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,32 +10,15 @@ package com.facebook.hermes.reactexecutor
1010import com.facebook.jni.HybridData
1111import com.facebook.jni.annotations.DoNotStrip
1212import com.facebook.react.bridge.JavaScriptExecutor
13- import com.facebook.react.common.build.ReactBuildConfig
14- import com.facebook.soloader.SoLoader
1513
1614public class HermesExecutor internal constructor(enableDebugger : Boolean , debuggerName : String ) :
1715 JavaScriptExecutor (initHybridDefaultConfig(enableDebugger, debuggerName)) {
1816
19- override fun getName (): String = " HermesExecutor$mode "
17+ override fun getName (): String = " HermesExecutor"
2018
2119 public companion object {
22- private var mode: String? = null
23-
24- init {
25- loadLibrary()
26- }
27-
28- @JvmStatic
29- @Throws(UnsatisfiedLinkError ::class )
30- public fun loadLibrary () {
31- if (mode == null ) {
32- // libhermesvm must be loaded explicitly to invoke its JNI_OnLoad.
33- SoLoader .loadLibrary(" hermesvm" )
34- SoLoader .loadLibrary(" hermes_executor" )
35- // libhermes_executor is built differently for Debug & Release so we load the proper mode.
36- mode = if (ReactBuildConfig .DEBUG ) " Debug" else " Release"
37- }
38- }
20+ /* * Retained for compatibility; this method no longer loads native libraries. */
21+ @JvmStatic public fun loadLibrary () {}
3922
4023 @DoNotStrip
4124 @JvmStatic
Original file line number Diff line number Diff line change @@ -25,7 +25,17 @@ public class HermesExecutorFactory : JavaScriptExecutorFactory {
2525 this .debuggerName = debuggerName
2626 }
2727
28- override fun create (): JavaScriptExecutor = HermesExecutor (enableDebugger, debuggerName)
28+ /* *
29+ * Compatibility factory for the unsupported legacy Hermes executor.
30+ *
31+ * @throws UnsupportedOperationException when creating an executor; use the New Architecture
32+ * runtime instead.
33+ */
34+ override fun create (): JavaScriptExecutor {
35+ throw UnsupportedOperationException (
36+ " HermesExecutorFactory is no longer supported. Use the New Architecture runtime instead." ,
37+ )
38+ }
2939
3040 override fun startSamplingProfiler () {
3141 enable()
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ */
7+
8+ package com.facebook.hermes.reactexecutor
9+
10+ import org.assertj.core.api.Assertions.assertThatThrownBy
11+ import org.junit.Test
12+
13+ class HermesExecutorFactoryTest {
14+ @Test
15+ fun loadLibraryIsNoOp () {
16+ HermesExecutor .loadLibrary()
17+ HermesExecutor .loadLibrary()
18+ }
19+
20+ @Test
21+ fun createIsUnsupported () {
22+ val factory = HermesExecutorFactory ()
23+ factory.setEnableDebugger(false )
24+ factory.setDebuggerName(" test" )
25+
26+ repeat(2 ) {
27+ assertThatThrownBy { factory.create() }
28+ .isInstanceOf(UnsupportedOperationException ::class .java)
29+ .hasMessage(
30+ " HermesExecutorFactory is no longer supported. Use the New Architecture runtime instead." ,
31+ )
32+ }
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments