/*
 * 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.uiapp;

import androidx.annotation.VisibleForTesting;
import com.facebook.jni.HybridData;
import com.facebook.react.ReactPackage;
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.soloader.SoLoader;
import java.util.List;

/** This class is responsible for creating all the TurboModules for the RNTester app. */
public class RNTesterTurboModuleManagerDelegate extends ReactPackageTurboModuleManagerDelegate {
  private static volatile boolean sIsSoLibraryLoaded;

  protected native HybridData initHybrid();

  @VisibleForTesting
  native boolean canCreateTurboModule(String moduleName);

  private RNTesterTurboModuleManagerDelegate(
      ReactApplicationContext context, List<ReactPackage> packages) {
    super(context, packages);
  }

  public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
    protected RNTesterTurboModuleManagerDelegate build(
        ReactApplicationContext context, List<ReactPackage> packages) {
      return new RNTesterTurboModuleManagerDelegate(context, packages);
    }
  }

  @Override
  protected void maybeLoadOtherSoLibraries() {
    maybeLoadSoLibraries();
  }

  // Prevents issues with initializer interruptions.
  private static synchronized void maybeLoadSoLibraries() {
    if (!sIsSoLibraryLoaded) {
      SoLoader.loadLibrary("rntester_appmodules");
      sIsSoLibraryLoaded = true;
    }
  }
}

@@ -1365,16 +1365,29 @@
 otected 
+synchronized 
 void may
@@ -1419,39 +1419,8 @@
 %7B%0A  
-  maybeLoadSoLibraries();%0A  %7D%0A%0A
   //
@@ -1472,68 +1472,8 @@
 ns.%0A
-  private static synchronized void maybeLoadSoLibraries() %7B%0A
     

Make So loading inside generated TMM delegates less confusing