summaryrefslogtreecommitdiff
path: root/test/common/runtime_state.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/common/runtime_state.cc')
-rw-r--r--test/common/runtime_state.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/test/common/runtime_state.cc b/test/common/runtime_state.cc
index 517eeaef96..635feffefb 100644
--- a/test/common/runtime_state.cc
+++ b/test/common/runtime_state.cc
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-#include "jni.h"
-
#include <android-base/logging.h>
#include <android-base/macros.h>
#include <sys/resource.h>
@@ -25,10 +23,12 @@
#include "base/enums.h"
#include "common_throws.h"
#include "dex/dex_file-inl.h"
+#include "gc/heap.h"
#include "instrumentation.h"
#include "jit/jit.h"
#include "jit/jit_code_cache.h"
#include "jit/profiling_info.h"
+#include "jni.h"
#include "jni/jni_internal.h"
#include "mirror/class-inl.h"
#include "mirror/class.h"
@@ -469,4 +469,18 @@ extern "C" JNIEXPORT void JNICALL Java_Main_setRlimitNoFile(JNIEnv*, jclass, jin
setrlimit(RLIMIT_NOFILE, &limit);
}
+extern "C" JNIEXPORT jboolean JNICALL Java_Main_isInImageSpace(JNIEnv* env,
+ [[maybe_unused]] jclass caller,
+ jclass cls) {
+ ScopedObjectAccess soa(env);
+
+ ObjPtr<mirror::Class> klass = soa.Decode<mirror::Class>(cls);
+ gc::space::Space* space =
+ Runtime::Current()->GetHeap()->FindSpaceFromObject(klass, /*fail_ok=*/true);
+ if (space == nullptr) {
+ return JNI_FALSE;
+ }
+ return space->IsImageSpace() ? JNI_TRUE : JNI_FALSE;
+}
+
} // namespace art