Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit a423db9

Browse files
authored
Statically create the MValue delegate (#1940)
1 parent 09e4671 commit a423db9

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

lib/src/main/java/com/couchbase/lite/CouchbaseLite.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.io.IOException;
2525
import java.io.InputStream;
2626
import java.lang.ref.SoftReference;
27-
import java.lang.reflect.Constructor;
2827
import java.util.HashMap;
2928
import java.util.Iterator;
3029
import java.util.Map;
@@ -47,7 +46,6 @@ public final class CouchbaseLite {
4746
private CouchbaseLite() {}
4847

4948
private static final String LITECORE_JNI_LIBRARY = "LiteCoreJNI";
50-
private static final String MVALUE_DELEGATE_CLASS = "com.couchbase.lite.MValueDelegate";
5149

5250
private static final AtomicReference<ExecutionService> EXECUTION_SERVICE = new AtomicReference<>();
5351
private static final AtomicReference<SoftReference<Context>> CONTEXT = new AtomicReference<>();
@@ -64,7 +62,7 @@ public static void init(@NonNull Context ctxt) {
6462

6563
System.loadLibrary(LITECORE_JNI_LIBRARY);
6664

67-
initMValue();
65+
MValue.registerDelegate(new MValueDelegate());
6866

6967
CONTEXT.set(new SoftReference<>(ctxt.getApplicationContext()));
7068

@@ -130,17 +128,6 @@ private static String verifyDir(@Nullable File dir) {
130128
throw new IllegalStateException("Cannot create or access directory at " + path);
131129
}
132130

133-
private static void initMValue() {
134-
try {
135-
final Constructor ctor = Class.forName(MVALUE_DELEGATE_CLASS).getDeclaredConstructor();
136-
ctor.setAccessible(true);
137-
MValue.registerDelegate((MValue.Delegate) ctor.newInstance());
138-
}
139-
catch (Exception e) {
140-
throw new IllegalStateException("Cannot initialize MValue delegate", e);
141-
}
142-
}
143-
144131
@NonNull
145132
private static Map<String, String> loadErrorMessages(@NonNull Context ctxt) {
146133
final Map<String, String> errorMessages = new HashMap<>();

0 commit comments

Comments
 (0)