0

I'm doing some work in art based on Android5.1, and I want to add a variable in Array class in Array.h(art/runtime/mirror/Array.h).

But when I add a "uint32_t tag" in the class, the system in emulator can not start up. So how can I add some variable in Array.h in Android5.1?

The crash log is like:

I/art     (   68): Pruning dalvik-cache since we are relocating an image and will need to recompile
I/art     (   68): RelocateImage: /system/bin/patchoat --input-image-location=/system/framework/boot.art --output-image-file=/data/dalvik-cache/arm/system@framework@boot.art --input-oat-location=/system/framework/boot.oat --output-oat-file=/data/dalvik-cache/arm/system@framework@boot.oat --instruction-set=arm --base-offset-delta=4898816
F/art     (   68): art/runtime/well_known_classes.cc:136] Couldn't find method "nativeLoad" with signature "(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/String;"
F/art     (   68): art/runtime/runtime.cc:289] Runtime aborting...
F/art     (   68): art/runtime/runtime.cc:289] Aborting thread:
F/art     (   68): art/runtime/runtime.cc:289] "main" prio=5 tid=1 Native (still starting up)
F/art     (   68): art/runtime/runtime.cc:289]   | group="" sCount=0 dsCount=0 obj=0x0 self=0xb4827800
F/art     (   68): art/runtime/runtime.cc:289]   | sysTid=68 nice=0 cgrp=default sched=0/0 handle=0xb6f75bec
F/art     (   68): art/runtime/runtime.cc:289]   | state=R schedstat=( 4510000000 20420000000 715 ) utm=337 stm=114 core=0 HZ=100
F/art     (   68): art/runtime/runtime.cc:289]   | stack=0xbe500000-0xbe502000 stackSize=8MB
F/art     (   68): art/runtime/runtime.cc:289]   | held mutexes= "abort lock" "mutator lock"(shared held)
F/art     (   68): art/runtime/runtime.cc:289]   native: #00 pc 00004ef0  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
F/art     (   68): art/runtime/runtime.cc:289]   native: #01 pc 000036d5  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
F/art     (   68): art/runtime/runtime.cc:289]   native: #02 pc 002458fd  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+68)
F/art     (   68): art/runtime/runtime.cc:289]   native: #03 pc 0022a051  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+144)
F/art     (   68): art/runtime/runtime.cc:289]   native: #04 pc 0021a44f  /system/lib/libart.so (art::AbortState::DumpThread(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, art::Thread*)+22)
F/art     (   68): art/runtime/runtime.cc:289]   native: #05 pc 0021a6b5  /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+364)
F/art     (   68): art/runtime/runtime.cc:289]   native: #06 pc 0021a881  /system/lib/libart.so (art::Runtime::Abort()+72)
F/art     (   68): art/runtime/runtime.cc:289]   native: #07 pc 000a7c57  /system/lib/libart.so (art::LogMessage::~LogMessage()+1066)
F/art     (   68): art/runtime/runtime.cc:289]   native: #08 pc 0025f515  /system/lib/libart.so (art::WellKnownClasses::LateInit(_JNIEnv*)+148)
F/art     (   68): art/runtime/runtime.cc:289]   native: #09 pc 0021a0ab  /system/lib/libart.so (art::Runtime::InitNativeMethods()+654)
F/art     (   68): art/runtime/runtime.cc:289]   native: #10 pc 0021af8b  /system/lib/libart.so (art::Runtime::Start()+670)
F/art     (   68): art/runtime/runtime.cc:289]   native: #11 pc 001d6577  /system/lib/libart.so (JNI_CreateJavaVM+526)
F/art     (   68): art/runtime/runtime.cc:289]   native: #12 pc 000604df  /system/lib/libandroid_runtime.so (android::AndroidRuntime::startVm(_JavaVM**, _JNIEnv**)+2286)
F/art     (   68): art/runtime/runtime.cc:289]   native: #13 pc 00060b27  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&)+258)
F/art     (   68): art/runtime/runtime.cc:289]   native: #14 pc 00001675  /system/bin/app_process32 (???)
F/art     (   68): art/runtime/runtime.cc:289]   native: #15 pc 00012dc9  /system/lib/libc.so (__libc_init+44)
F/art     (   68): art/runtime/runtime.cc:289]   native: #16 pc 000017b0  /system/bin/app_process32 (???)
F/art     (   68): art/runtime/runtime.cc:289]   (no managed stack frames)
F/art     (   68): art/runtime/runtime.cc:289] Pending exception java.lang.ExceptionInInitializerError thrown by 'unknown throw location'
F/art     (   68): art/runtime/runtime.cc:289] java.lang.ExceptionInInitializerError: 
F/art     (   68): art/runtime/runtime.cc:289]   at java.lang.String[] java.lang.Runtime.initLibPaths() (Runtime.java:73)
F/art     (   68): art/runtime/runtime.cc:289]   at void java.lang.Runtime.<init>() (Runtime.java:70)
F/art     (   68): art/runtime/runtime.cc:289]   at void java.lang.Runtime.<clinit>() (Runtime.java:65)
F/art     (   68): art/runtime/runtime.cc:289] Caused by: java.lang.ArrayIndexOutOfBoundsException: length=0; index=1
F/art     (   68): art/runtime/runtime.cc:289]   at java.lang.Object java.util.Hashtable.put(java.lang.Object, java.lang.Object) (Hashtable.java:384)
F/art     (   68): art/runtime/runtime.cc:289]   at java.util.Properties java.lang.System.initUnchangeableSystemProperties() (System.java:714)
F/art     (   68): art/runtime/runtime.cc:289]   at void java.lang.System.<clinit>() (System.java:108)
F/art     (   68): art/runtime/runtime.cc:289]   at java.lang.String[] java.lang.Runtime.initLibPaths() (Runtime.java:73)
F/art     (   68): art/runtime/runtime.cc:289]   at void java.lang.Runtime.<init>() (Runtime.java:70)
F/art     (   68): art/runtime/runtime.cc:289]   at void java.lang.Runtime.<clinit>() (Runtime.java:65)
F/art     (   68): art/runtime/runtime.cc:289] Dumping all threads without appropriate locks held: thread list lock mutator lock
F/art     (   68): art/runtime/runtime.cc:289] All threads:
F/art     (   68): art/runtime/runtime.cc:289] DALVIK THREADS (1):
F/art     (   68): art/runtime/runtime.cc:289] "main" prio=5 tid=1 Native (still starting up)
F/art     (   68): art/runtime/runtime.cc:289]   | group="" sCount=0 dsCount=0 obj=0x0 self=0xb4827800
F/art     (   68): art/runtime/runtime.cc:289]   | sysTid=68 nice=0 cgrp=default sched=0/0 handle=0xb6f75bec
F/art     (   68): art/runtime/runtime.cc:289]   | state=R schedstat=( 4610000000 20610000000 739 ) utm=344 stm=117 core=0 HZ=100
F/art     (   68): art/runtime/runtime.cc:289]   | stack=0xbe500000-0xbe502000 stackSize=8MB
F/art     (   68): art/runtime/runtime.cc:289]   | held mutexes= "abort lock"
F/art     (   68): art/runtime/runtime.cc:289]   native: #00 pc 00004ef0  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
F/art     (   68): art/runtime/runtime.cc:289]   native: #01 pc 000036d5  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
F/art     (   68): art/runtime/runtime.cc:289]   native: #02 pc 002458fd  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+68)
F/art     (   68): art/runtime/runtime.cc:289]   native: #03 pc 0022a051  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+144)
F/art     (   68): art/runtime/runtime.cc:289]   native: #04 pc 00232f85  /system/lib/libart.so (art::ThreadList::DumpLocked(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+104)
F/art     (   68): art/runtime/runtime.cc:289]   native: #05 pc 0021a635  /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+236)
F/art     (   68): art/runtime/runtime.cc:289]   native: #06 pc 0021a881  /system/lib/libart.so (art::Runtime::Abort()+72)
F/art     (   68): art/runtime/runtime.cc:289]   native: #07 pc 000a7c57  /system/lib/libart.so (art::LogMessage::~LogMessage()+1066)
F/art     (   68): art/runtime/runtime.cc:289]   native: #08 pc 0025f515  /system/lib/libart.so (art::WellKnownClasses::LateInit(_JNIEnv*)+148)
F/art     (   68): art/runtime/runtime.cc:289]   native: #09 pc 0021a0ab  /system/lib/libart.so (art::Runtime::InitNativeMethods()+654)
F/art     (   68): art/runtime/runtime.cc:289]   native: #10 pc 0021af8b  /system/lib/libart.so (art::Runtime::Start()+670)
F/art     (   68): art/runtime/runtime.cc:289]   native: #11 pc 001d6577  /system/lib/libart.so (JNI_CreateJavaVM+526)
F/art     (   68): art/runtime/runtime.cc:289]   native: #12 pc 000604df  /system/lib/libandroid_runtime.so (android::AndroidRuntime::startVm(_JavaVM**, _JNIEnv**)+2286)
F/art     (   68): art/runtime/runtime.cc:289]   native: #13 pc 00060b27  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&)+258)
F/art     (   68): art/runtime/runtime.cc:289]   native: #14 pc 00001675  /system/bin/app_process32 (???)
F/art     (   68): art/runtime/runtime.cc:289]   native: #15 pc 00012dc9  /system/lib/libc.so (__libc_init+44)
F/art     (   68): art/runtime/runtime.cc:289]   native: #16 pc 000017b0  /system/bin/app_process32 (???)
F/art     (   68): art/runtime/runtime.cc:289]   (no managed stack frames)
F/art     (   68): art/runtime/runtime.cc:289] 
F/art     (   68): art/runtime/runtime.cc:289] 
--------- beginning of crash
F/libc    (   68): Fatal signal 6 (SIGABRT), code -6 in tid 68 (main)
I/DEBUG   (   62): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (   62): Build fingerprint: '***'
I/DEBUG   (   62): Revision: '0'
I/DEBUG   (   62): ABI: 'arm'
I/DEBUG   (   62): pid: 68, tid: 68, name: main  >>> zygote <<<
I/DEBUG   (   62): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
I/DEBUG   (   62): Abort message: 'art/runtime/well_known_classes.cc:136] Couldn't find method "nativeLoad" with signature "(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/String;"'
I/DEBUG   (   62):     r0 00000000  r1 00000044  r2 00000006  r3 00000000
I/DEBUG   (   62):     r4 b6f75e38  r5 00000006  r6 00000002  r7 0000010c
I/DEBUG   (   62):     r8 00000082  r9 b486f550  sl b4827800  fp b486d480
I/DEBUG   (   62):     ip 00000044  sp becfd5f0  lr b6df3745  pc b6e176f0  cpsr 60000010
I/DEBUG   (   62): 
I/DEBUG   (   62): backtrace:
I/DEBUG   (   62):     #00 pc 0003a6f0  /system/lib/libc.so (tgkill+12)
I/DEBUG   (   62):     #01 pc 00016741  /system/lib/libc.so (pthread_kill+52)
I/DEBUG   (   62):     #02 pc 0001735f  /system/lib/libc.so (raise+10)
I/DEBUG   (   62):     #03 pc 00013b39  /system/lib/libc.so (__libc_android_abort+36)
I/DEBUG   (   62):     #04 pc 00012f18  /system/lib/libc.so (abort+4)
I/DEBUG   (   62):     #05 pc 0021a8d9  /system/lib/libart.so (art::Runtime::Abort()+160)
I/DEBUG   (   62):     #06 pc 000a7c57  /system/lib/libart.so (art::LogMessage::~LogMessage()+1066)
I/DEBUG   (   62):     #07 pc 0025f515  /system/lib/libart.so (art::WellKnownClasses::LateInit(_JNIEnv*)+148)
I/DEBUG   (   62):     #08 pc 0021a0ab  /system/lib/libart.so (art::Runtime::InitNativeMethods()+654)
I/DEBUG   (   62):     #09 pc 0021af8b  /system/lib/libart.so (art::Runtime::Start()+670)
I/DEBUG   (   62):     #10 pc 001d6577  /system/lib/libart.so (JNI_CreateJavaVM+526)
I/DEBUG   (   62):     #11 pc 000604df  /system/lib/libandroid_runtime.so (android::AndroidRuntime::startVm(_JavaVM**, _JNIEnv**)+2286)
I/DEBUG   (   62):     #12 pc 00060b27  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&)+258)
I/DEBUG   (   62):     #13 pc 00001675  /system/bin/app_process32
I/DEBUG   (   62):     #14 pc 00012dc9  /system/lib/libc.so (__libc_init+44)
I/DEBUG   (   62):     #15 pc 000017b0  /system/bin/app_process32
I/DEBUG   (   62): 
I/DEBUG   (   62): Tombstone written to: /data/tombstones/tombstone_00
  • C++ for Android? I remember it is Java – Khalil Khalaf May 09 '16 at 16:00
  • @FirstStep The "Array.h" in android source code (AOSP) – Kaiyuan Zhao May 09 '16 at 16:04
  • You can't just edit the source code of Android, as you've discovered. The target device will not have your changes on it, because obviously you can't rewrite the operating system by just installing your app. What are you trying to accomplish? – nasch May 09 '16 at 17:55
  • @nasch I can compile the source code and build an emulator to run the system which has been changed. I want to change the Array.h that I can put my tag into it, so each array in Java will has this tag. – Kaiyuan Zhao May 10 '16 at 01:03
  • 1
    I can see that, but what is the goal? I assume there's some underlying reason you want to do this. And your only plan is to run this on an emulator, you don't need to distribute it to anyone? I don't know anything about altering the android system so I can't help you there if that's really what you need to do. But this sounds like the kind of thing you could do with aspect-oriented programming. – nasch May 10 '16 at 03:29
  • @nasch The goal is to build my own android system. The command "lunch" in bash can be used to choose whether run the system on emulator or distribute a system. After I could run this on an emulator successfully, I can build a system to distribute. The system need to be flashed into an android phone, so it's not just aspect-oritented programming. – Kaiyuan Zhao May 10 '16 at 16:27

1 Answers1

0

Kaiyuan Zhao,

First of all, I am not sure why you would want EVERY array to have your tag, but the question is not really WHY, it is HOW.

Here is the HOW: You would need to change it in the .h file, and then go through the entirety of the android source code and change every call of an array element to take into account your change. This is a tedious and, in my thoughts, un-worthwhile task. Anyway, that is the HOW. It might be easier to write a script to take care of this for you in the end.

If you still want to do something like this, I wish you good luck and speedy grepping. Also, if you do come up with some sort of script, I would be very interested in seeing it. It would be a useful script in other situations as well.

Michael S.
  • 157
  • 11