blob: 2df1c0e6b0188c997133eb8c37ceb1abdc4002f8 [file] [log] [blame]
Elliott Hugheseac76672012-05-24 21:56:51 -07001/*
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
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_WELL_KNOWN_CLASSES_H_
18#define ART_RUNTIME_WELL_KNOWN_CLASSES_H_
Elliott Hugheseac76672012-05-24 21:56:51 -070019
Elliott Hughes76b61672012-12-12 17:47:30 -080020#include "base/mutex.h"
Elliott Hugheseac76672012-05-24 21:56:51 -070021#include "jni.h"
22
23namespace art {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080024namespace mirror {
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070025class Class;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080026} // namespace mirror
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070027
Elliott Hugheseac76672012-05-24 21:56:51 -070028// Various classes used in JNI. We cache them so we don't have to keep looking
29// them up. Similar to libcore's JniConstants (except there's no overlap, so
30// we keep them separate).
31
Mathieu Chartier987ccff2013-07-08 11:05:21 -070032jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, const char* name, const char* signature);
33
Elliott Hugheseac76672012-05-24 21:56:51 -070034struct WellKnownClasses {
Brian Carlstromea46f952013-07-30 01:26:50 -070035 public:
Ian Rogersef28b142012-11-30 14:22:18 -080036 static void Init(JNIEnv* env); // Run before native methods are registered.
37 static void LateInit(JNIEnv* env); // Run after native methods are registered.
Elliott Hugheseac76672012-05-24 21:56:51 -070038
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080039 static mirror::Class* ToClass(jclass global_jclass)
Ian Rogersb726dcb2012-09-05 08:57:23 -070040 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070041
Elliott Hugheseac76672012-05-24 21:56:51 -070042 static jclass com_android_dex_Dex;
Mathieu Chartier6bcae8f2014-09-04 18:33:17 -070043 static jclass dalvik_system_DexFile;
44 static jclass dalvik_system_DexPathList;
Andreas Gampec8ccf682014-09-29 20:07:43 -070045 static jclass dalvik_system_DexPathList__Element;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070046 static jclass dalvik_system_PathClassLoader;
Mathieu Chartier6bcae8f2014-09-04 18:33:17 -070047 static jclass java_lang_BootClassLoader;
Elliott Hugheseac76672012-05-24 21:56:51 -070048 static jclass java_lang_ClassLoader;
49 static jclass java_lang_ClassNotFoundException;
50 static jclass java_lang_Daemons;
51 static jclass java_lang_Error;
Ian Rogersaf6e67a2013-01-16 08:38:37 -080052 static jclass java_lang_Object;
Mathieu Chartier66f19252012-09-18 08:57:04 -070053 static jclass java_lang_reflect_AbstractMethod;
Brian Carlstromea46f952013-07-30 01:26:50 -070054 static jclass java_lang_reflect_ArtMethod;
55 static jclass java_lang_reflect_Constructor;
56 static jclass java_lang_reflect_Field;
57 static jclass java_lang_reflect_Method;
Elliott Hugheseac76672012-05-24 21:56:51 -070058 static jclass java_lang_reflect_Proxy;
Elliott Hughesa4f94742012-05-29 16:28:38 -070059 static jclass java_lang_RuntimeException;
Ian Rogers120f1c72012-09-28 17:17:10 -070060 static jclass java_lang_StackOverflowError;
Ian Rogersdd157d72014-05-15 14:47:50 -070061 static jclass java_lang_String;
Mathieu Chartier987ccff2013-07-08 11:05:21 -070062 static jclass java_lang_System;
Elliott Hugheseac76672012-05-24 21:56:51 -070063 static jclass java_lang_Thread;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070064 static jclass java_lang_ThreadGroup;
Andreas Gampec8ccf682014-09-29 20:07:43 -070065 static jclass java_lang_Thread__UncaughtExceptionHandler;
Elliott Hughesa4f94742012-05-29 16:28:38 -070066 static jclass java_lang_Throwable;
Sebastien Hertze49e1952014-10-13 11:27:13 +020067 static jclass java_util_ArrayList;
Andreas Gampe7ea6f792014-07-14 16:21:44 -070068 static jclass java_util_Collections;
Elliott Hughesaecb5f32013-03-28 08:27:38 -070069 static jclass java_nio_DirectByteBuffer;
Andreas Gampe7ea6f792014-07-14 16:21:44 -070070 static jclass libcore_util_EmptyArray;
Elliott Hugheseac76672012-05-24 21:56:51 -070071 static jclass org_apache_harmony_dalvik_ddmc_Chunk;
72 static jclass org_apache_harmony_dalvik_ddmc_DdmServer;
73
74 static jmethodID com_android_dex_Dex_create;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070075 static jmethodID java_lang_Boolean_valueOf;
76 static jmethodID java_lang_Byte_valueOf;
77 static jmethodID java_lang_Character_valueOf;
Elliott Hughesa4f94742012-05-29 16:28:38 -070078 static jmethodID java_lang_ClassLoader_loadClass;
Elliott Hugheseac76672012-05-24 21:56:51 -070079 static jmethodID java_lang_ClassNotFoundException_init;
80 static jmethodID java_lang_Daemons_requestHeapTrim;
81 static jmethodID java_lang_Daemons_start;
Mathieu Chartiercef50f02014-12-09 17:38:52 -080082 static jmethodID java_lang_Daemons_stop;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070083 static jmethodID java_lang_Double_valueOf;
84 static jmethodID java_lang_Float_valueOf;
85 static jmethodID java_lang_Integer_valueOf;
86 static jmethodID java_lang_Long_valueOf;
Elliott Hughesa4f94742012-05-29 16:28:38 -070087 static jmethodID java_lang_ref_FinalizerReference_add;
88 static jmethodID java_lang_ref_ReferenceQueue_add;
Brian Carlstromea46f952013-07-30 01:26:50 -070089 static jmethodID java_lang_reflect_Proxy_invoke;
Ian Rogersef28b142012-11-30 14:22:18 -080090 static jmethodID java_lang_Runtime_nativeLoad;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070091 static jmethodID java_lang_Short_valueOf;
Mathieu Chartier987ccff2013-07-08 11:05:21 -070092 static jmethodID java_lang_System_runFinalization;
Elliott Hugheseac76672012-05-24 21:56:51 -070093 static jmethodID java_lang_Thread_init;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070094 static jmethodID java_lang_Thread_run;
Andreas Gampec8ccf682014-09-29 20:07:43 -070095 static jmethodID java_lang_Thread__UncaughtExceptionHandler_uncaughtException;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070096 static jmethodID java_lang_ThreadGroup_removeThread;
Elliott Hughesaecb5f32013-03-28 08:27:38 -070097 static jmethodID java_nio_DirectByteBuffer_init;
Elliott Hugheseac76672012-05-24 21:56:51 -070098 static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast;
99 static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch;
100
Mathieu Chartier6bcae8f2014-09-04 18:33:17 -0700101 static jfieldID dalvik_system_DexFile_cookie;
102 static jfieldID dalvik_system_DexPathList_dexElements;
Andreas Gampec8ccf682014-09-29 20:07:43 -0700103 static jfieldID dalvik_system_DexPathList__Element_dexFile;
Mathieu Chartier6bcae8f2014-09-04 18:33:17 -0700104 static jfieldID dalvik_system_PathClassLoader_pathList;
Brian Carlstromea46f952013-07-30 01:26:50 -0700105 static jfieldID java_lang_reflect_AbstractMethod_artMethod;
Elliott Hugheseac76672012-05-24 21:56:51 -0700106 static jfieldID java_lang_reflect_Proxy_h;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -0700107 static jfieldID java_lang_Thread_daemon;
108 static jfieldID java_lang_Thread_group;
109 static jfieldID java_lang_Thread_lock;
110 static jfieldID java_lang_Thread_name;
111 static jfieldID java_lang_Thread_priority;
112 static jfieldID java_lang_Thread_uncaughtHandler;
Anwar Ghuloum3c50a4b2013-06-21 13:05:23 -0700113 static jfieldID java_lang_Thread_nativePeer;
Sebastien Hertze49e1952014-10-13 11:27:13 +0200114 static jfieldID java_lang_ThreadGroup_groups;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -0700115 static jfieldID java_lang_ThreadGroup_mainThreadGroup;
116 static jfieldID java_lang_ThreadGroup_name;
Sebastien Hertze49e1952014-10-13 11:27:13 +0200117 static jfieldID java_lang_ThreadGroup_parent;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -0700118 static jfieldID java_lang_ThreadGroup_systemThreadGroup;
Brian Carlstrom34375312014-09-10 23:10:47 -0700119 static jfieldID java_lang_Throwable_cause;
120 static jfieldID java_lang_Throwable_detailMessage;
121 static jfieldID java_lang_Throwable_stackTrace;
122 static jfieldID java_lang_Throwable_stackState;
123 static jfieldID java_lang_Throwable_suppressedExceptions;
Elliott Hughesaecb5f32013-03-28 08:27:38 -0700124 static jfieldID java_nio_DirectByteBuffer_capacity;
125 static jfieldID java_nio_DirectByteBuffer_effectiveDirectAddress;
Sebastien Hertze49e1952014-10-13 11:27:13 +0200126 static jfieldID java_util_ArrayList_array;
127 static jfieldID java_util_ArrayList_size;
Brian Carlstrom34375312014-09-10 23:10:47 -0700128 static jfieldID java_util_Collections_EMPTY_LIST;
129 static jfieldID libcore_util_EmptyArray_STACK_TRACE_ELEMENT;
Elliott Hugheseac76672012-05-24 21:56:51 -0700130 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_data;
131 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_length;
132 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_offset;
133 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_type;
134};
135
136} // namespace art
137
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700138#endif // ART_RUNTIME_WELL_KNOWN_CLASSES_H_