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 | #ifndef ART_SRC_WELL_KNOWN_CLASSES_H_ |
| 18 | #define ART_SRC_WELL_KNOWN_CLASSES_H_ |
| 19 | |
| 20 | #include "jni.h" |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 21 | #include "mutex.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 22 | |
| 23 | namespace art { |
| 24 | |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 25 | class Class; |
| 26 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 27 | // Various classes used in JNI. We cache them so we don't have to keep looking |
| 28 | // them up. Similar to libcore's JniConstants (except there's no overlap, so |
| 29 | // we keep them separate). |
| 30 | |
| 31 | struct WellKnownClasses { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 32 | static void InitClasses(JNIEnv* env); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 33 | static void Init(JNIEnv* env); |
| 34 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 35 | static Class* ToClass(jclass global_jclass) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame^] | 36 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 37 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 38 | static jclass com_android_dex_Dex; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 39 | static jclass dalvik_system_PathClassLoader; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 40 | static jclass java_lang_ClassLoader; |
| 41 | static jclass java_lang_ClassNotFoundException; |
| 42 | static jclass java_lang_Daemons; |
| 43 | static jclass java_lang_Error; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 44 | static jclass java_lang_reflect_InvocationHandler; |
| 45 | static jclass java_lang_reflect_Method; |
| 46 | static jclass java_lang_reflect_Proxy; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 47 | static jclass java_lang_RuntimeException; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 48 | static jclass java_lang_Thread; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 49 | static jclass java_lang_ThreadGroup; |
| 50 | static jclass java_lang_ThreadLock; |
| 51 | static jclass java_lang_Thread$UncaughtExceptionHandler; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 52 | static jclass java_lang_Throwable; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 53 | static jclass java_nio_ReadWriteDirectByteBuffer; |
| 54 | static jclass org_apache_harmony_dalvik_ddmc_Chunk; |
| 55 | static jclass org_apache_harmony_dalvik_ddmc_DdmServer; |
| 56 | |
| 57 | static jmethodID com_android_dex_Dex_create; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 58 | static jmethodID java_lang_Boolean_valueOf; |
| 59 | static jmethodID java_lang_Byte_valueOf; |
| 60 | static jmethodID java_lang_Character_valueOf; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 61 | static jmethodID java_lang_ClassLoader_loadClass; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 62 | static jmethodID java_lang_ClassNotFoundException_init; |
Mathieu Chartier | 7664f5c | 2012-06-08 18:15:32 -0700 | [diff] [blame] | 63 | static jmethodID java_lang_Daemons_requestGC; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 64 | static jmethodID java_lang_Daemons_requestHeapTrim; |
| 65 | static jmethodID java_lang_Daemons_start; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 66 | static jmethodID java_lang_Double_valueOf; |
| 67 | static jmethodID java_lang_Float_valueOf; |
| 68 | static jmethodID java_lang_Integer_valueOf; |
| 69 | static jmethodID java_lang_Long_valueOf; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 70 | static jmethodID java_lang_ref_FinalizerReference_add; |
| 71 | static jmethodID java_lang_ref_ReferenceQueue_add; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 72 | static jmethodID java_lang_reflect_InvocationHandler_invoke; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 73 | static jmethodID java_lang_Short_valueOf; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 74 | static jmethodID java_lang_Thread_init; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 75 | static jmethodID java_lang_Thread_run; |
| 76 | static jmethodID java_lang_Thread$UncaughtExceptionHandler_uncaughtException; |
| 77 | static jmethodID java_lang_ThreadGroup_removeThread; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 78 | static jmethodID java_nio_ReadWriteDirectByteBuffer_init; |
| 79 | static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast; |
| 80 | static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch; |
| 81 | |
| 82 | static jfieldID java_lang_reflect_Proxy_h; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 83 | static jfieldID java_lang_Thread_daemon; |
| 84 | static jfieldID java_lang_Thread_group; |
| 85 | static jfieldID java_lang_Thread_lock; |
| 86 | static jfieldID java_lang_Thread_name; |
| 87 | static jfieldID java_lang_Thread_priority; |
| 88 | static jfieldID java_lang_Thread_uncaughtHandler; |
| 89 | static jfieldID java_lang_Thread_vmData; |
| 90 | static jfieldID java_lang_ThreadGroup_mainThreadGroup; |
| 91 | static jfieldID java_lang_ThreadGroup_name; |
| 92 | static jfieldID java_lang_ThreadGroup_systemThreadGroup; |
| 93 | static jfieldID java_lang_ThreadLock_thread; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 94 | static jfieldID java_nio_ReadWriteDirectByteBuffer_capacity; |
| 95 | static jfieldID java_nio_ReadWriteDirectByteBuffer_effectiveDirectAddress; |
| 96 | static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_data; |
| 97 | static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_length; |
| 98 | static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_offset; |
| 99 | static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_type; |
| 100 | }; |
| 101 | |
| 102 | } // namespace art |
| 103 | |
| 104 | #endif // ART_SRC_WELL_KNOWN_CLASSES_H_ |