JavaVM
*
javaVM;
env
-
>GetJavaVM(&javaVM);
JavaVMExt
*
javaVMExt
=
(JavaVMExt
*
) javaVM;
void
*
runtime
=
javaVMExt
-
>runtime;
LOGV(
"runtime ptr: %p, vmExtPtr: %p"
, runtime, javaVMExt);
LOGV(
"std::unique_ptr<PartialRuntime13> size: %d"
, sizeof (std::unique_ptr<PartialRuntime13>));
LOGV(
"get_heap_to_jvm_offset size: %d"
, get_heap_to_jvm_offset());
const
int
MAX
=
5000
;
int
offsetOfVmExt
=
findOffset(runtime,
0
,
MAX
, (void
*
) javaVMExt);
LOGV(
"offsetOfVmExt: %d"
, offsetOfVmExt);
int
head_offset
=
offsetOfVmExt
-
get_heap_to_jvm_offset()
+
sizeof (void
*
);
LOGV(
"head_offset: %d"
, head_offset);
void
*
heap
=
(char
*
)runtime
+
head_offset;
AndroidRunAPI
*
androidRunApi
=
AndroidRunAPI::getInstance();
LOGV(
"1"
);
androidRunApi
-
>partialRuntime
=
static_cast<PartialRuntime
*
>(heap);
getAndroidSystemFunction();
LOGV(
"1"
);
LookupClassesVisitor visitor(env, javaVMExt);
LOGV(
"1 %p"
,androidRunApi
-
>VisitClassLoaders);
androidRunApi
-
>VisitClassLoaders(androidRunApi
-
>partialRuntime
-
>class_linker_,&visitor);
LOGV(
"1"
);
std::vector<jobject> vectorObject
=
visitor.getVecObj();
jclass ClassLoader_cls
=
env
-
>FindClass(
"java/lang/ClassLoader"
);
LOGV(
"2"
);
for
(auto it
=
vectorObject.begin(); it !
=
vectorObject.end();
/
*
no increment here
*
/
) {
jboolean re
=
env
-
>IsInstanceOf(
*
it,ClassLoader_cls);
if
(!re){
it
=
vectorObject.erase(it);
}
else
{
+
+
it;
}
}
jobjectArray objectArray
=
env
-
>NewObjectArray(vectorObject.size(), ClassLoader_cls, NULL);
for
(
int
i
=
0
;i<vectorObject.size();i
+
+
){
env
-
>SetObjectArrayElement(objectArray, i, vectorObject[i]);
}
return
objectArray;