When a transmit from java to native occurs, dvm sets up a native stack. In dvmCallJNIMethod(), dvmPlatformInvoke is used to call the native method(signature inMethod.insns).
/*package*/final class DexPathList {privatestaticfinal String DEX_SUFFIX = ".dex";privatestaticfinal String JAR_SUFFIX = ".jar";privatestaticfinal String ZIP_SUFFIX = ".zip";privatestaticfinal String APK_SUFFIX = ".apk";/** class definition context */privatefinal ClassLoader definingContext;/** list of dex/resource (class path) elements 也就是dex列表咯*/privatefinal Element[] dexElements;/** list of native library directory elements */privatefinal File[] nativeLibraryDirectories;
那么当需要加载某个类的时候,是怎么加载的呢?
//BaseDexClassLoader: @Overrideprotected Class> findClass(String name) throws ClassNotFoundException { List suppressedExceptions = new ArrayList(); Class c = pathList.findClass(name, suppressedExceptions); if (c == null) { ClassNotFoundException cnfe = new ClassNotFoundException("Didn't find class \"" + name + "\" on path: " + pathList); for (Throwable t : suppressedExceptions) { cnfe.addSuppressed(t); } throw cnfe; } return c; }
findClass()方法如下:
public Class findClass(String name, Listsuppressed) { for (Element element : dexElements) { DexFile dex = element.dexFile; if (dex != null) { Class clazz = dex.loadClassBinaryName(name, definingContext, suppressed); if (clazz != null) { return clazz; } } } if (dexElementsSuppressedExceptions != null) { suppressed.addAll(Arrays.asList(dexElementsSuppressedExceptions)); } returnnull; }
Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ...
[详细]
Explore how Matterverse is redefining the metaverse experience, creating immersive and meaningful virtual environments that foster genuine connections and economic opportunities. ...
[详细]