Android init.rc BOOTCLASSPATH

來源:互聯網
上載者:User

 BOOTCLASSPATH 不添加jar包路徑,系統啟動後將無法找到自訂JAVA層系統服務的相關類,這是由於自訂系統服務jar包是Dalvik所需的基本庫檔案。如果不添加相關路徑會報如下錯誤:

W/dalvikvm( 2582): Unable to resolve superclass of Lcom/android/server/yourdir/yourService; (1633)
W/dalvikvm( 2582): Link of class 'Lcom/android/server/yourdir/yourService;' failed
D/dalvikvm( 2582): DexOpt: unable to opt direct call 0x276b at 0x258 in Lcom/android/server/ServerThread;.run

三篇必看原理文章:

Android
類實現探索-系統基礎類

Dalvik 分析之準備篇

Dalvik 分析 - Class載入篇


init.rc:
export BOOTCLASSPATH /system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar
BOOTCLASSPATH=/ango/system/framework/core.jar:/ango/system/framework/bouncycastle.jar:/ango/system/framework/ext.jar:/ango/system/framework/framework.jar:/ango/system/framework/android.policy.jar:/ango/system/framework/services.jar:/ango/system/framework/core-junit.jar

d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/Init.c
//getenv of classpath and BOOTCLASSPATH configed by init.rc
static void setCommandLineDefaults()
putenv("BOOTCLASSPATH=/ango/system/framework/core.jar:/ango/system/framework/bouncycastle.jar:/ango/system/framework/ext.jar:/ango/system/framework/framework.jar:/ango/system/framework/android.policy.jar:/ango/system/framework/services.jar:/ango/system/framework/core-junit.jar");
    envStr = getenv("BOOTCLASSPATH");
    if (envStr != NULL)
        gDvm.bootClassPathStr = strdup(envStr);
    else
        gDvm.bootClassPathStr = strdup(".");


d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/oo/Class.c
/*
 * Prepare a ClassPathEntry struct, which at this point only has a valid
 * filename.  We need to figure out what kind of file it is, and for
 * everything other than directories we need to open it up and see
 * what's inside.
 */
static bool prepareCpe(ClassPathEntry* cpe, bool isBootstrap)
/*
 * Convert a colon-separated list of directories, Zip files, and DEX files
 * into an array of ClassPathEntry structs.
 *
 * During normal startup we fail if there are no entries, because we won't
 * get very far without the basic language support classes, but if we're
 * optimizing a DEX file we allow it.
 *
 * If entries are added or removed from the bootstrap class path, the
 * dependencies in the DEX files will break, and everything except the
 * very first entry will need to be regenerated.
 */
static ClassPathEntry* processClassPath(const char* pathStr, bool isBootstrap)
/*
 * Initialize the bootstrap class loader.
 *
 * Call this after the bootclasspath string has been finalized.
 */
bool dvmClassStartup(void)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.