Codebase list mozc / 01b1e5b
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
3 changed file(s) with 14 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
143143 return result;
144144 }
145145
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,
147150 jclass clazz,
148151 jstring user_profile_directory_path,
149152 jstring data_file_path) {
150153 if (g_session_handler) {
151 return;
154 return true;
152155 }
153156
154157 // First of all, set the user profile directory.
165168 JavaHttpClientProxy::SetJavaVM(nullptr);
166169 SystemUtil::SetUserProfileDirectory(original_dir);
167170 LOG(DFATAL) << "Failed to create Mozc session handler";
168 return;
171 return false;
169172 }
170173
171174 // Starts usage stats timer.
172175 Scheduler::AddJob(GetJobSetting());
176 return true;
173177 }
174178
175179 jstring JNICALL getVersion(JNIEnv *env) {
214218 "([B)[B",
215219 reinterpret_cast<void*>(&mozc::jni::evalCommand)},
216220 {"onPostLoad",
217 "(Ljava/lang/String;Ljava/lang/String;)V",
221 "(Ljava/lang/String;Ljava/lang/String;)Z",
218222 reinterpret_cast<void*>(&mozc::jni::onPostLoad)},
219223 {"getVersion",
220224 "()Ljava/lang/String;",
7575 message.append(" Server:").append(nativeVersion);
7676 throw new UnsatisfiedLinkError(message.toString());
7777 }
78 onPostLoad(userProfileDirectoryPath, dataFilePath);
78 if (!onPostLoad(userProfileDirectoryPath, dataFilePath)) {
79 MozcLog.e("onPostLoad fails");
80 return;
81 }
7982 isLoaded = true;
8083 MozcLog.d("end MozcJNI#load " + System.nanoTime());
8184 }
97100 * for JNI called when the shared object is loaded, because we need to pass the file path
98101 * of data file from Java as only Java knows where the data is in our context.
99102 */
100 private static synchronized native void onPostLoad(
103 private static synchronized native boolean onPostLoad(
101104 String userProfileDirectoryPath, String dataFilePath);
102105
103106 /**
00 MAJOR=2
11 MINOR=18
2 BUILD=2573
2 BUILD=2574
33 REVISION=102
44 # CAUTION: NACL_DICTIONARY_VERSION is going to be migrated to ENGINE_VERSION.
55 # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be