Skip to content

Commit b994323

Browse files
authored
Merge pull request #508 from cundong/dev
add createClassLoader LOG
2 parents 9f817cd + a1ec73c commit b994323

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/loader2/Loader.java

+25
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import java.util.Map;
6060
import java.util.Set;
6161

62+
import static com.qihoo360.replugin.helper.LogDebug.LOADER_TAG;
6263
import static com.qihoo360.replugin.helper.LogDebug.LOG;
6364
import static com.qihoo360.replugin.helper.LogDebug.PLUGIN_TAG;
6465
import static com.qihoo360.replugin.helper.LogRelease.LOGR;
@@ -314,6 +315,18 @@ final boolean loadDex(ClassLoader parent, int load) {
314315
parent = getClass().getClassLoader().getParent(); // TODO: 这里直接用父类加载器
315316
}
316317
String soDir = mPackageInfo.applicationInfo.nativeLibraryDir;
318+
319+
long begin = 0;
320+
boolean isDexExist = false;
321+
322+
if (LOG) {
323+
begin = System.currentTimeMillis();
324+
File dexFile = mPluginObj.mInfo.getDexFile();
325+
if (dexFile.exists() && dexFile.length() > 0) {
326+
isDexExist = true;
327+
}
328+
}
329+
317330
mClassLoader = RePlugin.getConfig().getCallbacks().createPluginClassLoader(mPluginObj.mInfo, mPath, out, soDir, parent);
318331
Log.i("dex", "load " + mPath + " = " + mClassLoader);
319332

@@ -324,6 +337,18 @@ final boolean loadDex(ClassLoader parent, int load) {
324337
return false;
325338
}
326339

340+
if (LOG) {
341+
if (!isDexExist) {
342+
Log.d(LOADER_TAG, " --释放DEX, " + "(plugin=" + mPluginName + ", version=" + mPluginObj.mInfo.getVersion() + ")"
343+
+ ", use:" + (System.currentTimeMillis() - begin)
344+
+ ", process:" + IPC.getCurrentProcessName());
345+
} else {
346+
Log.d(LOADER_TAG, " --无需释放DEX, " + "(plugin=" + mPluginName + ", version=" + mPluginObj.mInfo.getVersion() + ")"
347+
+ ", use:" + (System.currentTimeMillis() - begin)
348+
+ ", process:" + IPC.getCurrentProcessName());
349+
}
350+
}
351+
327352
// 缓存表:ClassLoader
328353
synchronized (Plugin.FILENAME_2_DEX) {
329354
Plugin.FILENAME_2_DEX.put(mPath, new WeakReference<>(mClassLoader));

replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/replugin/helper/LogDebug.java

+5
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,9 @@ public static int printPluginInfo(PluginInfo pi, int load) {
264264
* @deprecated 为兼容卫士,以后干掉
265265
*/
266266
public static final String MISC_TAG = "ws002";
267+
268+
/**
269+
* createClassLoader TAG
270+
*/
271+
public static final String LOADER_TAG = "createClassLoader";
267272
}

0 commit comments

Comments
 (0)