art: Add FileDescriptor fields to native Core Platform API
Adds descriptor and ownerId to whitelisted native Core Platform API.
Bug: 144502743
Bug: 150680645
Test: art/test/run-test --host 001-HelloWorld
Test: art/tools/run-libcore-tests.sh --mode=host --variant=X64
Change-Id: Ifd25daed95516b27eaae4b034fdc45f77ea25a74
diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc
index c55a134..f33600f 100644
--- a/runtime/hidden_api.cc
+++ b/runtime/hidden_api.cc
@@ -122,6 +122,8 @@
// The following fields in WellKnownClasses correspond to private fields in the Core Platform
// API that cannot be otherwise expressed and propagated through tooling (b/144502743).
jfieldID private_core_platform_api_fields[] = {
+ WellKnownClasses::java_io_FileDescriptor_descriptor,
+ WellKnownClasses::java_io_FileDescriptor_ownerId,
WellKnownClasses::java_nio_Buffer_address,
WellKnownClasses::java_nio_Buffer_elementSizeShift,
WellKnownClasses::java_nio_Buffer_limit,
diff --git a/runtime/well_known_classes.cc b/runtime/well_known_classes.cc
index 017dd0e..fabd4db 100644
--- a/runtime/well_known_classes.cc
+++ b/runtime/well_known_classes.cc
@@ -130,6 +130,8 @@
jfieldID WellKnownClasses::dalvik_system_DexPathList_dexElements;
jfieldID WellKnownClasses::dalvik_system_DexPathList__Element_dexFile;
jfieldID WellKnownClasses::dalvik_system_VMRuntime_nonSdkApiUsageConsumer;
+jfieldID WellKnownClasses::java_io_FileDescriptor_descriptor;
+jfieldID WellKnownClasses::java_io_FileDescriptor_ownerId;
jfieldID WellKnownClasses::java_lang_Thread_parkBlocker;
jfieldID WellKnownClasses::java_lang_Thread_daemon;
jfieldID WellKnownClasses::java_lang_Thread_group;
@@ -418,6 +420,10 @@
dalvik_system_DexPathList__Element_dexFile = CacheField(env, dalvik_system_DexPathList__Element, false, "dexFile", "Ldalvik/system/DexFile;");
dalvik_system_VMRuntime_nonSdkApiUsageConsumer = CacheField(env, dalvik_system_VMRuntime, true, "nonSdkApiUsageConsumer", "Ljava/util/function/Consumer;");
+ ScopedLocalRef<jclass> java_io_FileDescriptor(env, env->FindClass("java/io/FileDescriptor"));
+ java_io_FileDescriptor_descriptor = CacheField(env, java_io_FileDescriptor.get(), false, "descriptor", "I");
+ java_io_FileDescriptor_ownerId = CacheField(env, java_io_FileDescriptor.get(), false, "ownerId", "J");
+
java_lang_Thread_parkBlocker = CacheField(env, java_lang_Thread, false, "parkBlocker", "Ljava/lang/Object;");
java_lang_Thread_daemon = CacheField(env, java_lang_Thread, false, "daemon", "Z");
java_lang_Thread_group = CacheField(env, java_lang_Thread, false, "group", "Ljava/lang/ThreadGroup;");
@@ -543,6 +549,8 @@
dalvik_system_BaseDexClassLoader_getLdLibraryPath = nullptr;
dalvik_system_VMRuntime_runFinalization = nullptr;
dalvik_system_VMRuntime_hiddenApiUsed = nullptr;
+ java_io_FileDescriptor_descriptor = nullptr;
+ java_io_FileDescriptor_ownerId = nullptr;
java_lang_Boolean_valueOf = nullptr;
java_lang_Byte_valueOf = nullptr;
java_lang_Character_valueOf = nullptr;
diff --git a/runtime/well_known_classes.h b/runtime/well_known_classes.h
index 4a35210..6f67fde6 100644
--- a/runtime/well_known_classes.h
+++ b/runtime/well_known_classes.h
@@ -143,6 +143,8 @@
static jfieldID dalvik_system_DexPathList_dexElements;
static jfieldID dalvik_system_DexPathList__Element_dexFile;
static jfieldID dalvik_system_VMRuntime_nonSdkApiUsageConsumer;
+ static jfieldID java_io_FileDescriptor_descriptor;
+ static jfieldID java_io_FileDescriptor_ownerId;
static jfieldID java_lang_Thread_parkBlocker;
static jfieldID java_lang_Thread_daemon;
static jfieldID java_lang_Thread_group;