Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "well_known_classes.h" |
| 18 | |
| 19 | #include <stdlib.h> |
| 20 | |
Elliott Hughes | 07ed66b | 2012-12-12 18:34:25 -0800 | [diff] [blame] | 21 | #include "base/logging.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 22 | #include "mirror/class.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 23 | #include "ScopedLocalRef.h" |
Brian Carlstrom | a3d2718 | 2013-11-05 23:22:27 -0800 | [diff] [blame] | 24 | #include "thread-inl.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 25 | |
| 26 | namespace art { |
| 27 | |
| 28 | jclass WellKnownClasses::com_android_dex_Dex; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 29 | jclass WellKnownClasses::dalvik_system_PathClassLoader; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 30 | jclass WellKnownClasses::java_lang_ClassLoader; |
| 31 | jclass WellKnownClasses::java_lang_ClassNotFoundException; |
| 32 | jclass WellKnownClasses::java_lang_Daemons; |
| 33 | jclass WellKnownClasses::java_lang_Error; |
Ian Rogers | af6e67a | 2013-01-16 08:38:37 -0800 | [diff] [blame] | 34 | jclass WellKnownClasses::java_lang_Object; |
Mathieu Chartier | 66f1925 | 2012-09-18 08:57:04 -0700 | [diff] [blame] | 35 | jclass WellKnownClasses::java_lang_reflect_AbstractMethod; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 36 | jclass WellKnownClasses::java_lang_reflect_ArtMethod; |
| 37 | jclass WellKnownClasses::java_lang_reflect_Constructor; |
| 38 | jclass WellKnownClasses::java_lang_reflect_Field; |
| 39 | jclass WellKnownClasses::java_lang_reflect_Method; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 40 | jclass WellKnownClasses::java_lang_reflect_Proxy; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 41 | jclass WellKnownClasses::java_lang_RuntimeException; |
Ian Rogers | 120f1c7 | 2012-09-28 17:17:10 -0700 | [diff] [blame] | 42 | jclass WellKnownClasses::java_lang_StackOverflowError; |
Ian Rogers | dd157d7 | 2014-05-15 14:47:50 -0700 | [diff] [blame] | 43 | jclass WellKnownClasses::java_lang_String; |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 44 | jclass WellKnownClasses::java_lang_System; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 45 | jclass WellKnownClasses::java_lang_Thread; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 46 | jclass WellKnownClasses::java_lang_Thread$UncaughtExceptionHandler; |
| 47 | jclass WellKnownClasses::java_lang_ThreadGroup; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 48 | jclass WellKnownClasses::java_lang_Throwable; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 49 | jclass WellKnownClasses::java_nio_DirectByteBuffer; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 50 | jclass WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk; |
| 51 | jclass WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer; |
| 52 | |
| 53 | jmethodID WellKnownClasses::com_android_dex_Dex_create; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 54 | jmethodID WellKnownClasses::java_lang_Boolean_valueOf; |
| 55 | jmethodID WellKnownClasses::java_lang_Byte_valueOf; |
| 56 | jmethodID WellKnownClasses::java_lang_Character_valueOf; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 57 | jmethodID WellKnownClasses::java_lang_ClassLoader_loadClass; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 58 | jmethodID WellKnownClasses::java_lang_ClassNotFoundException_init; |
Mathieu Chartier | 7664f5c | 2012-06-08 18:15:32 -0700 | [diff] [blame] | 59 | jmethodID WellKnownClasses::java_lang_Daemons_requestGC; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 60 | jmethodID WellKnownClasses::java_lang_Daemons_requestHeapTrim; |
| 61 | jmethodID WellKnownClasses::java_lang_Daemons_start; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 62 | jmethodID WellKnownClasses::java_lang_Double_valueOf; |
| 63 | jmethodID WellKnownClasses::java_lang_Float_valueOf; |
| 64 | jmethodID WellKnownClasses::java_lang_Integer_valueOf; |
| 65 | jmethodID WellKnownClasses::java_lang_Long_valueOf; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 66 | jmethodID WellKnownClasses::java_lang_ref_FinalizerReference_add; |
| 67 | jmethodID WellKnownClasses::java_lang_ref_ReferenceQueue_add; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 68 | jmethodID WellKnownClasses::java_lang_reflect_Proxy_invoke; |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 69 | jmethodID WellKnownClasses::java_lang_Runtime_nativeLoad; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 70 | jmethodID WellKnownClasses::java_lang_Short_valueOf; |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 71 | jmethodID WellKnownClasses::java_lang_System_runFinalization = NULL; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 72 | jmethodID WellKnownClasses::java_lang_Thread_init; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 73 | jmethodID WellKnownClasses::java_lang_Thread_run; |
| 74 | jmethodID WellKnownClasses::java_lang_Thread$UncaughtExceptionHandler_uncaughtException; |
| 75 | jmethodID WellKnownClasses::java_lang_ThreadGroup_removeThread; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 76 | jmethodID WellKnownClasses::java_nio_DirectByteBuffer_init; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 77 | jmethodID WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer_broadcast; |
| 78 | jmethodID WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer_dispatch; |
| 79 | |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 80 | jfieldID WellKnownClasses::java_lang_Thread_daemon; |
| 81 | jfieldID WellKnownClasses::java_lang_Thread_group; |
| 82 | jfieldID WellKnownClasses::java_lang_Thread_lock; |
| 83 | jfieldID WellKnownClasses::java_lang_Thread_name; |
| 84 | jfieldID WellKnownClasses::java_lang_Thread_priority; |
| 85 | jfieldID WellKnownClasses::java_lang_Thread_uncaughtHandler; |
Anwar Ghuloum | 3c50a4b | 2013-06-21 13:05:23 -0700 | [diff] [blame] | 86 | jfieldID WellKnownClasses::java_lang_Thread_nativePeer; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 87 | jfieldID WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup; |
| 88 | jfieldID WellKnownClasses::java_lang_ThreadGroup_name; |
| 89 | jfieldID WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 90 | jfieldID WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod; |
| 91 | jfieldID WellKnownClasses::java_lang_reflect_Field_artField; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 92 | jfieldID WellKnownClasses::java_lang_reflect_Proxy_h; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 93 | jfieldID WellKnownClasses::java_nio_DirectByteBuffer_capacity; |
| 94 | jfieldID WellKnownClasses::java_nio_DirectByteBuffer_effectiveDirectAddress; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 95 | jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_data; |
| 96 | jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_length; |
| 97 | jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_offset; |
| 98 | jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_type; |
| 99 | |
| 100 | static jclass CacheClass(JNIEnv* env, const char* jni_class_name) { |
| 101 | ScopedLocalRef<jclass> c(env, env->FindClass(jni_class_name)); |
| 102 | if (c.get() == NULL) { |
| 103 | LOG(FATAL) << "Couldn't find class: " << jni_class_name; |
| 104 | } |
| 105 | return reinterpret_cast<jclass>(env->NewGlobalRef(c.get())); |
| 106 | } |
| 107 | |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 108 | static jfieldID CacheField(JNIEnv* env, jclass c, bool is_static, const char* name, const char* signature) { |
| 109 | jfieldID fid = is_static ? env->GetStaticFieldID(c, name, signature) : env->GetFieldID(c, name, signature); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 110 | if (fid == NULL) { |
| 111 | LOG(FATAL) << "Couldn't find field \"" << name << "\" with signature \"" << signature << "\""; |
| 112 | } |
| 113 | return fid; |
| 114 | } |
| 115 | |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 116 | jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, const char* name, const char* signature) { |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 117 | jmethodID mid = is_static ? env->GetStaticMethodID(c, name, signature) : env->GetMethodID(c, name, signature); |
| 118 | if (mid == NULL) { |
| 119 | LOG(FATAL) << "Couldn't find method \"" << name << "\" with signature \"" << signature << "\""; |
| 120 | } |
| 121 | return mid; |
| 122 | } |
| 123 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 124 | static jmethodID CachePrimitiveBoxingMethod(JNIEnv* env, char prim_name, const char* boxed_name) { |
| 125 | ScopedLocalRef<jclass> boxed_class(env, env->FindClass(boxed_name)); |
| 126 | return CacheMethod(env, boxed_class.get(), true, "valueOf", |
| 127 | StringPrintf("(%c)L%s;", prim_name, boxed_name).c_str()); |
| 128 | } |
| 129 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 130 | void WellKnownClasses::Init(JNIEnv* env) { |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 131 | com_android_dex_Dex = CacheClass(env, "com/android/dex/Dex"); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 132 | dalvik_system_PathClassLoader = CacheClass(env, "dalvik/system/PathClassLoader"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 133 | java_lang_ClassLoader = CacheClass(env, "java/lang/ClassLoader"); |
| 134 | java_lang_ClassNotFoundException = CacheClass(env, "java/lang/ClassNotFoundException"); |
| 135 | java_lang_Daemons = CacheClass(env, "java/lang/Daemons"); |
Ian Rogers | af6e67a | 2013-01-16 08:38:37 -0800 | [diff] [blame] | 136 | java_lang_Object = CacheClass(env, "java/lang/Object"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 137 | java_lang_Error = CacheClass(env, "java/lang/Error"); |
Mathieu Chartier | 66f1925 | 2012-09-18 08:57:04 -0700 | [diff] [blame] | 138 | java_lang_reflect_AbstractMethod = CacheClass(env, "java/lang/reflect/AbstractMethod"); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 139 | java_lang_reflect_ArtMethod = CacheClass(env, "java/lang/reflect/ArtMethod"); |
| 140 | java_lang_reflect_Constructor = CacheClass(env, "java/lang/reflect/Constructor"); |
| 141 | java_lang_reflect_Field = CacheClass(env, "java/lang/reflect/Field"); |
| 142 | java_lang_reflect_Method = CacheClass(env, "java/lang/reflect/Method"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 143 | java_lang_reflect_Proxy = CacheClass(env, "java/lang/reflect/Proxy"); |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 144 | java_lang_RuntimeException = CacheClass(env, "java/lang/RuntimeException"); |
Ian Rogers | 120f1c7 | 2012-09-28 17:17:10 -0700 | [diff] [blame] | 145 | java_lang_StackOverflowError = CacheClass(env, "java/lang/StackOverflowError"); |
Ian Rogers | dd157d7 | 2014-05-15 14:47:50 -0700 | [diff] [blame] | 146 | java_lang_String = CacheClass(env, "java/lang/String"); |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 147 | java_lang_System = CacheClass(env, "java/lang/System"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 148 | java_lang_Thread = CacheClass(env, "java/lang/Thread"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 149 | java_lang_Thread$UncaughtExceptionHandler = CacheClass(env, "java/lang/Thread$UncaughtExceptionHandler"); |
| 150 | java_lang_ThreadGroup = CacheClass(env, "java/lang/ThreadGroup"); |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 151 | java_lang_Throwable = CacheClass(env, "java/lang/Throwable"); |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 152 | java_nio_DirectByteBuffer = CacheClass(env, "java/nio/DirectByteBuffer"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 153 | org_apache_harmony_dalvik_ddmc_Chunk = CacheClass(env, "org/apache/harmony/dalvik/ddmc/Chunk"); |
| 154 | org_apache_harmony_dalvik_ddmc_DdmServer = CacheClass(env, "org/apache/harmony/dalvik/ddmc/DdmServer"); |
| 155 | |
| 156 | com_android_dex_Dex_create = CacheMethod(env, com_android_dex_Dex, true, "create", "(Ljava/nio/ByteBuffer;)Lcom/android/dex/Dex;"); |
| 157 | java_lang_ClassNotFoundException_init = CacheMethod(env, java_lang_ClassNotFoundException, false, "<init>", "(Ljava/lang/String;Ljava/lang/Throwable;)V"); |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 158 | java_lang_ClassLoader_loadClass = CacheMethod(env, java_lang_ClassLoader, false, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;"); |
Mathieu Chartier | 7664f5c | 2012-06-08 18:15:32 -0700 | [diff] [blame] | 159 | |
| 160 | java_lang_Daemons_requestGC = CacheMethod(env, java_lang_Daemons, true, "requestGC", "()V"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 161 | java_lang_Daemons_requestHeapTrim = CacheMethod(env, java_lang_Daemons, true, "requestHeapTrim", "()V"); |
| 162 | java_lang_Daemons_start = CacheMethod(env, java_lang_Daemons, true, "start", "()V"); |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 163 | |
| 164 | ScopedLocalRef<jclass> java_lang_ref_FinalizerReference(env, env->FindClass("java/lang/ref/FinalizerReference")); |
| 165 | java_lang_ref_FinalizerReference_add = CacheMethod(env, java_lang_ref_FinalizerReference.get(), true, "add", "(Ljava/lang/Object;)V"); |
| 166 | ScopedLocalRef<jclass> java_lang_ref_ReferenceQueue(env, env->FindClass("java/lang/ref/ReferenceQueue")); |
| 167 | java_lang_ref_ReferenceQueue_add = CacheMethod(env, java_lang_ref_ReferenceQueue.get(), true, "add", "(Ljava/lang/ref/Reference;)V"); |
| 168 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 169 | java_lang_reflect_Proxy_invoke = CacheMethod(env, java_lang_reflect_Proxy, true, "invoke", "(Ljava/lang/reflect/Proxy;Ljava/lang/reflect/ArtMethod;[Ljava/lang/Object;)Ljava/lang/Object;"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 170 | java_lang_Thread_init = CacheMethod(env, java_lang_Thread, false, "<init>", "(Ljava/lang/ThreadGroup;Ljava/lang/String;IZ)V"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 171 | java_lang_Thread_run = CacheMethod(env, java_lang_Thread, false, "run", "()V"); |
| 172 | java_lang_Thread$UncaughtExceptionHandler_uncaughtException = CacheMethod(env, java_lang_Thread$UncaughtExceptionHandler, false, "uncaughtException", "(Ljava/lang/Thread;Ljava/lang/Throwable;)V"); |
| 173 | java_lang_ThreadGroup_removeThread = CacheMethod(env, java_lang_ThreadGroup, false, "removeThread", "(Ljava/lang/Thread;)V"); |
Elliott Hughes | b568121 | 2013-03-29 17:29:22 -0700 | [diff] [blame] | 174 | java_nio_DirectByteBuffer_init = CacheMethod(env, java_nio_DirectByteBuffer, false, "<init>", "(JI)V"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 175 | org_apache_harmony_dalvik_ddmc_DdmServer_broadcast = CacheMethod(env, org_apache_harmony_dalvik_ddmc_DdmServer, true, "broadcast", "(I)V"); |
| 176 | org_apache_harmony_dalvik_ddmc_DdmServer_dispatch = CacheMethod(env, org_apache_harmony_dalvik_ddmc_DdmServer, true, "dispatch", "(I[BII)Lorg/apache/harmony/dalvik/ddmc/Chunk;"); |
| 177 | |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 178 | java_lang_Thread_daemon = CacheField(env, java_lang_Thread, false, "daemon", "Z"); |
| 179 | java_lang_Thread_group = CacheField(env, java_lang_Thread, false, "group", "Ljava/lang/ThreadGroup;"); |
Elliott Hughes | c5dc2ff | 2013-01-09 13:44:30 -0800 | [diff] [blame] | 180 | java_lang_Thread_lock = CacheField(env, java_lang_Thread, false, "lock", "Ljava/lang/Object;"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 181 | java_lang_Thread_name = CacheField(env, java_lang_Thread, false, "name", "Ljava/lang/String;"); |
| 182 | java_lang_Thread_priority = CacheField(env, java_lang_Thread, false, "priority", "I"); |
| 183 | java_lang_Thread_uncaughtHandler = CacheField(env, java_lang_Thread, false, "uncaughtHandler", "Ljava/lang/Thread$UncaughtExceptionHandler;"); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 184 | java_lang_Thread_nativePeer = CacheField(env, java_lang_Thread, false, "nativePeer", "J"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 185 | java_lang_ThreadGroup_mainThreadGroup = CacheField(env, java_lang_ThreadGroup, true, "mainThreadGroup", "Ljava/lang/ThreadGroup;"); |
| 186 | java_lang_ThreadGroup_name = CacheField(env, java_lang_ThreadGroup, false, "name", "Ljava/lang/String;"); |
| 187 | java_lang_ThreadGroup_systemThreadGroup = CacheField(env, java_lang_ThreadGroup, true, "systemThreadGroup", "Ljava/lang/ThreadGroup;"); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 188 | java_lang_reflect_AbstractMethod_artMethod = CacheField(env, java_lang_reflect_AbstractMethod, false, "artMethod", "Ljava/lang/reflect/ArtMethod;"); |
| 189 | java_lang_reflect_Field_artField = CacheField(env, java_lang_reflect_Field, false, "artField", "Ljava/lang/reflect/ArtField;"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 190 | java_lang_reflect_Proxy_h = CacheField(env, java_lang_reflect_Proxy, false, "h", "Ljava/lang/reflect/InvocationHandler;"); |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 191 | java_nio_DirectByteBuffer_capacity = CacheField(env, java_nio_DirectByteBuffer, false, "capacity", "I"); |
Elliott Hughes | 2e8a4fc | 2013-03-29 16:33:52 -0700 | [diff] [blame] | 192 | java_nio_DirectByteBuffer_effectiveDirectAddress = CacheField(env, java_nio_DirectByteBuffer, false, "effectiveDirectAddress", "J"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 193 | org_apache_harmony_dalvik_ddmc_Chunk_data = CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "data", "[B"); |
| 194 | org_apache_harmony_dalvik_ddmc_Chunk_length = CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "length", "I"); |
| 195 | org_apache_harmony_dalvik_ddmc_Chunk_offset = CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "offset", "I"); |
| 196 | org_apache_harmony_dalvik_ddmc_Chunk_type = CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "type", "I"); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 197 | |
| 198 | java_lang_Boolean_valueOf = CachePrimitiveBoxingMethod(env, 'Z', "java/lang/Boolean"); |
| 199 | java_lang_Byte_valueOf = CachePrimitiveBoxingMethod(env, 'B', "java/lang/Byte"); |
| 200 | java_lang_Character_valueOf = CachePrimitiveBoxingMethod(env, 'C', "java/lang/Character"); |
| 201 | java_lang_Double_valueOf = CachePrimitiveBoxingMethod(env, 'D', "java/lang/Double"); |
| 202 | java_lang_Float_valueOf = CachePrimitiveBoxingMethod(env, 'F', "java/lang/Float"); |
| 203 | java_lang_Integer_valueOf = CachePrimitiveBoxingMethod(env, 'I', "java/lang/Integer"); |
| 204 | java_lang_Long_valueOf = CachePrimitiveBoxingMethod(env, 'J', "java/lang/Long"); |
| 205 | java_lang_Short_valueOf = CachePrimitiveBoxingMethod(env, 'S', "java/lang/Short"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 208 | void WellKnownClasses::LateInit(JNIEnv* env) { |
| 209 | ScopedLocalRef<jclass> java_lang_Runtime(env, env->FindClass("java/lang/Runtime")); |
Elliott Hughes | c8fece3 | 2013-01-02 11:27:23 -0800 | [diff] [blame] | 210 | java_lang_Runtime_nativeLoad = CacheMethod(env, java_lang_Runtime.get(), true, "nativeLoad", "(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/String;"); |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 211 | } |
| 212 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 213 | mirror::Class* WellKnownClasses::ToClass(jclass global_jclass) { |
| 214 | return reinterpret_cast<mirror::Class*>(Thread::Current()->DecodeJObject(global_jclass)); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | } // namespace art |