More robust logic for loading JNI
BUG=
TEST=
REF_BUG=29050519
REF_CL=124151532
REF_TIME=2016-06-07T02:37:00+09:00
REF_TIME_RAW=1465234620 +0900
Tsuyoshi Matsuzaki
7 years ago
143 | 143 |
return result;
|
144 | 144 |
}
|
145 | 145 |
|
146 | |
void JNICALL onPostLoad(JNIEnv *env,
|
|
146 |
// Does post-load tasks.
|
|
147 |
// Returns true if the task succeeded
|
|
148 |
// or SessionHandler has already been initializaed.
|
|
149 |
jboolean JNICALL onPostLoad(JNIEnv *env,
|
147 | 150 |
jclass clazz,
|
148 | 151 |
jstring user_profile_directory_path,
|
149 | 152 |
jstring data_file_path) {
|
150 | 153 |
if (g_session_handler) {
|
151 | |
return;
|
|
154 |
return true;
|
152 | 155 |
}
|
153 | 156 |
|
154 | 157 |
// First of all, set the user profile directory.
|
|
165 | 168 |
JavaHttpClientProxy::SetJavaVM(nullptr);
|
166 | 169 |
SystemUtil::SetUserProfileDirectory(original_dir);
|
167 | 170 |
LOG(DFATAL) << "Failed to create Mozc session handler";
|
168 | |
return;
|
|
171 |
return false;
|
169 | 172 |
}
|
170 | 173 |
|
171 | 174 |
// Starts usage stats timer.
|
172 | 175 |
Scheduler::AddJob(GetJobSetting());
|
|
176 |
return true;
|
173 | 177 |
}
|
174 | 178 |
|
175 | 179 |
jstring JNICALL getVersion(JNIEnv *env) {
|
|
214 | 218 |
"([B)[B",
|
215 | 219 |
reinterpret_cast<void*>(&mozc::jni::evalCommand)},
|
216 | 220 |
{"onPostLoad",
|
217 | |
"(Ljava/lang/String;Ljava/lang/String;)V",
|
|
221 |
"(Ljava/lang/String;Ljava/lang/String;)Z",
|
218 | 222 |
reinterpret_cast<void*>(&mozc::jni::onPostLoad)},
|
219 | 223 |
{"getVersion",
|
220 | 224 |
"()Ljava/lang/String;",
|
75 | 75 |
message.append(" Server:").append(nativeVersion);
|
76 | 76 |
throw new UnsatisfiedLinkError(message.toString());
|
77 | 77 |
}
|
78 | |
onPostLoad(userProfileDirectoryPath, dataFilePath);
|
|
78 |
if (!onPostLoad(userProfileDirectoryPath, dataFilePath)) {
|
|
79 |
MozcLog.e("onPostLoad fails");
|
|
80 |
return;
|
|
81 |
}
|
79 | 82 |
isLoaded = true;
|
80 | 83 |
MozcLog.d("end MozcJNI#load " + System.nanoTime());
|
81 | 84 |
}
|
|
97 | 100 |
* for JNI called when the shared object is loaded, because we need to pass the file path
|
98 | 101 |
* of data file from Java as only Java knows where the data is in our context.
|
99 | 102 |
*/
|
100 | |
private static synchronized native void onPostLoad(
|
|
103 |
private static synchronized native boolean onPostLoad(
|
101 | 104 |
String userProfileDirectoryPath, String dataFilePath);
|
102 | 105 |
|
103 | 106 |
/**
|
0 | 0 |
MAJOR=2
|
1 | 1 |
MINOR=18
|
2 | |
BUILD=2573
|
|
2 |
BUILD=2574
|
3 | 3 |
REVISION=102
|
4 | 4 |
# CAUTION: NACL_DICTIONARY_VERSION is going to be migrated to ENGINE_VERSION.
|
5 | 5 |
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
|