blob: 8170520d45e4f55e15910ba20af7f12c91512207 [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
17#ifndef ART_SRC_WELL_KNOWN_CLASSES_H_
18#define ART_SRC_WELL_KNOWN_CLASSES_H_
19
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
32struct WellKnownClasses {
Ian Rogers00f7d0e2012-07-19 15:28:27 -070033 static void InitClasses(JNIEnv* env);
Ian Rogersef28b142012-11-30 14:22:18 -080034 static void Init(JNIEnv* env); // Run before native methods are registered.
35 static void LateInit(JNIEnv* env); // Run after native methods are registered.
Elliott Hugheseac76672012-05-24 21:56:51 -070036
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080037 static mirror::Class* ToClass(jclass global_jclass)
Ian Rogersb726dcb2012-09-05 08:57:23 -070038 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070039
Elliott Hugheseac76672012-05-24 21:56:51 -070040 static jclass com_android_dex_Dex;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070041 static jclass dalvik_system_PathClassLoader;
Elliott Hugheseac76672012-05-24 21:56:51 -070042 static jclass java_lang_ClassLoader;
43 static jclass java_lang_ClassNotFoundException;
44 static jclass java_lang_Daemons;
45 static jclass java_lang_Error;
Ian Rogersaf6e67a2013-01-16 08:38:37 -080046 static jclass java_lang_Object;
Elliott Hugheseac76672012-05-24 21:56:51 -070047 static jclass java_lang_reflect_InvocationHandler;
Mathieu Chartier66f19252012-09-18 08:57:04 -070048 static jclass java_lang_reflect_AbstractMethod;
Elliott Hugheseac76672012-05-24 21:56:51 -070049 static jclass java_lang_reflect_Proxy;
Elliott Hughesa4f94742012-05-29 16:28:38 -070050 static jclass java_lang_RuntimeException;
Ian Rogers120f1c72012-09-28 17:17:10 -070051 static jclass java_lang_StackOverflowError;
Elliott Hugheseac76672012-05-24 21:56:51 -070052 static jclass java_lang_Thread;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070053 static jclass java_lang_ThreadGroup;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070054 static jclass java_lang_Thread$UncaughtExceptionHandler;
Elliott Hughesa4f94742012-05-29 16:28:38 -070055 static jclass java_lang_Throwable;
Elliott Hughesaecb5f32013-03-28 08:27:38 -070056 static jclass java_nio_DirectByteBuffer;
Elliott Hugheseac76672012-05-24 21:56:51 -070057 static jclass org_apache_harmony_dalvik_ddmc_Chunk;
58 static jclass org_apache_harmony_dalvik_ddmc_DdmServer;
59
60 static jmethodID com_android_dex_Dex_create;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070061 static jmethodID java_lang_Boolean_valueOf;
62 static jmethodID java_lang_Byte_valueOf;
63 static jmethodID java_lang_Character_valueOf;
Elliott Hughesa4f94742012-05-29 16:28:38 -070064 static jmethodID java_lang_ClassLoader_loadClass;
Elliott Hugheseac76672012-05-24 21:56:51 -070065 static jmethodID java_lang_ClassNotFoundException_init;
Mathieu Chartier7664f5c2012-06-08 18:15:32 -070066 static jmethodID java_lang_Daemons_requestGC;
Elliott Hugheseac76672012-05-24 21:56:51 -070067 static jmethodID java_lang_Daemons_requestHeapTrim;
68 static jmethodID java_lang_Daemons_start;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070069 static jmethodID java_lang_Double_valueOf;
70 static jmethodID java_lang_Float_valueOf;
71 static jmethodID java_lang_Integer_valueOf;
72 static jmethodID java_lang_Long_valueOf;
Elliott Hughesa4f94742012-05-29 16:28:38 -070073 static jmethodID java_lang_ref_FinalizerReference_add;
74 static jmethodID java_lang_ref_ReferenceQueue_add;
Elliott Hugheseac76672012-05-24 21:56:51 -070075 static jmethodID java_lang_reflect_InvocationHandler_invoke;
Ian Rogersef28b142012-11-30 14:22:18 -080076 static jmethodID java_lang_Runtime_nativeLoad;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070077 static jmethodID java_lang_Short_valueOf;
Elliott Hugheseac76672012-05-24 21:56:51 -070078 static jmethodID java_lang_Thread_init;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070079 static jmethodID java_lang_Thread_run;
80 static jmethodID java_lang_Thread$UncaughtExceptionHandler_uncaughtException;
81 static jmethodID java_lang_ThreadGroup_removeThread;
Elliott Hughesaecb5f32013-03-28 08:27:38 -070082 static jmethodID java_nio_DirectByteBuffer_init;
Elliott Hugheseac76672012-05-24 21:56:51 -070083 static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast;
84 static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch;
85
86 static jfieldID java_lang_reflect_Proxy_h;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070087 static jfieldID java_lang_Thread_daemon;
88 static jfieldID java_lang_Thread_group;
89 static jfieldID java_lang_Thread_lock;
90 static jfieldID java_lang_Thread_name;
91 static jfieldID java_lang_Thread_priority;
92 static jfieldID java_lang_Thread_uncaughtHandler;
Anwar Ghuloum3c50a4b2013-06-21 13:05:23 -070093 static jfieldID java_lang_Thread_nativePeer;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070094 static jfieldID java_lang_ThreadGroup_mainThreadGroup;
95 static jfieldID java_lang_ThreadGroup_name;
96 static jfieldID java_lang_ThreadGroup_systemThreadGroup;
Elliott Hughesaecb5f32013-03-28 08:27:38 -070097 static jfieldID java_nio_DirectByteBuffer_capacity;
98 static jfieldID java_nio_DirectByteBuffer_effectiveDirectAddress;
Elliott Hugheseac76672012-05-24 21:56:51 -070099 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_data;
100 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_length;
101 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_offset;
102 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_type;
103};
104
105} // namespace art
106
107#endif // ART_SRC_WELL_KNOWN_CLASSES_H_