1// 2// This file was generated by third_party/jni_zero/jni_generator.py 3// 4package org.jni_zero.samples; 5 6import org.jni_zero.CheckDiscard; 7import org.jni_zero.JniStaticTestMocker; 8import org.jni_zero.NativeLibraryLoadedStatus; 9import org.jni_zero.module_GEN_JNI; 10import org.jni_zero.NativeMethods; 11 12@CheckDiscard("crbug.com/993421") 13class SampleModuleJni implements SampleModule.Natives { 14 private static SampleModule.Natives testInstance; 15 16 public static final JniStaticTestMocker<SampleModule.Natives> TEST_HOOKS = 17 new JniStaticTestMocker<SampleModule.Natives>() { 18 @Override 19 public void setInstanceForTesting(SampleModule.Natives instance) { 20 if (!module_GEN_JNI.TESTING_ENABLED) { 21 throw new RuntimeException( 22 "Tried to set a JNI mock when mocks aren't enabled!"); 23 } 24 testInstance = instance; 25 } 26 }; 27 28 @Override 29 public boolean bar(int a) { 30 return (boolean) module_GEN_JNI.org_jni_1zero_samples_SampleModule_bar(a); 31 } 32 33 @Override 34 public void foo() { 35 module_GEN_JNI.org_jni_1zero_samples_SampleModule_foo(); 36 } 37 38 public static SampleModule.Natives get() { 39 if (module_GEN_JNI.TESTING_ENABLED) { 40 if (testInstance != null) { 41 return testInstance; 42 } 43 if (module_GEN_JNI.REQUIRE_MOCK) { 44 throw new UnsupportedOperationException( 45 "No mock found for the native implementation of SampleModule.Natives. " 46 + "The current configuration requires implementations be mocked."); 47 } 48 } 49 NativeLibraryLoadedStatus.checkLoaded(); 50 return new SampleModuleJni(); 51 } 52} 53