17
17
#include " firestore/src/jni/arena_ref.h"
18
18
19
19
#include < atomic>
20
+ #include < utility>
20
21
21
22
#include " firestore/src/android/firestore_android.h"
22
23
#include " firestore/src/jni/env.h"
@@ -31,6 +32,9 @@ namespace jni {
31
32
namespace {
32
33
33
34
HashMap* gArenaRefHashMap = nullptr ;
35
+ jclass gHashMapClass = nullptr ;
36
+ jclass gLongClass = nullptr ;
37
+ jmethodID gLongConstructor = nullptr ;
34
38
std::mutex mutex_;
35
39
36
40
int64_t GetNextArenaRefKey () {
@@ -115,7 +119,8 @@ ArenaRef::~ArenaRef() {
115
119
}
116
120
117
121
Local<Long> ArenaRef::key_object (Env& env) const {
118
- return Long::Create (env, key_);
122
+ jobject key = env.get ()->NewObject (gLongClass , gLongConstructor , key_);
123
+ return {env.get (), key};
119
124
}
120
125
121
126
void ArenaRef::Initialize (Env& env) {
@@ -124,6 +129,13 @@ void ArenaRef::Initialize(Env& env) {
124
129
}
125
130
Global<HashMap> hash_map (HashMap::Create (env));
126
131
gArenaRefHashMap = new HashMap (hash_map.release ());
132
+
133
+ gHashMapClass = env.get ()->FindClass (" java/util/HashMap" );
134
+ gHashMapClass = static_cast <jclass>(env.get ()->NewGlobalRef (gHashMapClass ));
135
+
136
+ gLongClass = env.get ()->FindClass (" java/lang/Long" );
137
+ gLongClass = static_cast <jclass>(env.get ()->NewGlobalRef (gLongClass ));
138
+ gLongConstructor = env.get ()->GetMethodID (gLongClass , " <init>" , " (J)V" );
127
139
}
128
140
129
141
Local<Object> ArenaRef::get (Env& env) const {
0 commit comments