blob: f6c2930909b79246bc40220f4b58c472ff3b3b58 [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;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070043 static jclass dalvik_system_PathClassLoader;
Elliott Hugheseac76672012-05-24 21:56:51 -070044 static jclass java_lang_ClassLoader;
45 static jclass java_lang_ClassNotFoundException;
46 static jclass java_lang_Daemons;
47 static jclass java_lang_Error;
Ian Rogersaf6e67a2013-01-16 08:38:37 -080048 static jclass java_lang_Object;
Mathieu Chartier66f19252012-09-18 08:57:04 -070049 static jclass java_lang_reflect_AbstractMethod;
Brian Carlstromea46f952013-07-30 01:26:50 -070050 static jclass java_lang_reflect_ArtMethod;
51 static jclass java_lang_reflect_Constructor;
52 static jclass java_lang_reflect_Field;
53 static jclass java_lang_reflect_Method;
Elliott Hugheseac76672012-05-24 21:56:51 -070054 static jclass java_lang_reflect_Proxy;
Elliott Hughesa4f94742012-05-29 16:28:38 -070055 static jclass java_lang_RuntimeException;
Ian Rogers120f1c72012-09-28 17:17:10 -070056 static jclass java_lang_StackOverflowError;
Ian Rogersdd157d72014-05-15 14:47:50 -070057 static jclass java_lang_String;
Mathieu Chartier987ccff2013-07-08 11:05:21 -070058 static jclass java_lang_System;
Elliott Hugheseac76672012-05-24 21:56:51 -070059 static jclass java_lang_Thread;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070060 static jclass java_lang_ThreadGroup;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070061 static jclass java_lang_Thread$UncaughtExceptionHandler;
Elliott Hughesa4f94742012-05-29 16:28:38 -070062 static jclass java_lang_Throwable;
Elliott Hughesaecb5f32013-03-28 08:27:38 -070063 static jclass java_nio_DirectByteBuffer;
Elliott Hugheseac76672012-05-24 21:56:51 -070064 static jclass org_apache_harmony_dalvik_ddmc_Chunk;
65 static jclass org_apache_harmony_dalvik_ddmc_DdmServer;
66
67 static jmethodID com_android_dex_Dex_create;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070068 static jmethodID java_lang_Boolean_valueOf;
69 static jmethodID java_lang_Byte_valueOf;
70 static jmethodID java_lang_Character_valueOf;
Elliott Hughesa4f94742012-05-29 16:28:38 -070071 static jmethodID java_lang_ClassLoader_loadClass;
Elliott Hugheseac76672012-05-24 21:56:51 -070072 static jmethodID java_lang_ClassNotFoundException_init;
Mathieu Chartier7664f5c2012-06-08 18:15:32 -070073 static jmethodID java_lang_Daemons_requestGC;
Elliott Hugheseac76672012-05-24 21:56:51 -070074 static jmethodID java_lang_Daemons_requestHeapTrim;
75 static jmethodID java_lang_Daemons_start;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070076 static jmethodID java_lang_Double_valueOf;
77 static jmethodID java_lang_Float_valueOf;
78 static jmethodID java_lang_Integer_valueOf;
79 static jmethodID java_lang_Long_valueOf;
Elliott Hughesa4f94742012-05-29 16:28:38 -070080 static jmethodID java_lang_ref_FinalizerReference_add;
81 static jmethodID java_lang_ref_ReferenceQueue_add;
Brian Carlstromea46f952013-07-30 01:26:50 -070082 static jmethodID java_lang_reflect_Proxy_invoke;
Ian Rogersef28b142012-11-30 14:22:18 -080083 static jmethodID java_lang_Runtime_nativeLoad;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070084 static jmethodID java_lang_Short_valueOf;
Mathieu Chartier987ccff2013-07-08 11:05:21 -070085 static jmethodID java_lang_System_runFinalization;
Elliott Hugheseac76672012-05-24 21:56:51 -070086 static jmethodID java_lang_Thread_init;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070087 static jmethodID java_lang_Thread_run;
88 static jmethodID java_lang_Thread$UncaughtExceptionHandler_uncaughtException;
89 static jmethodID java_lang_ThreadGroup_removeThread;
Elliott Hughesaecb5f32013-03-28 08:27:38 -070090 static jmethodID java_nio_DirectByteBuffer_init;
Elliott Hugheseac76672012-05-24 21:56:51 -070091 static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast;
92 static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch;
93
Brian Carlstromea46f952013-07-30 01:26:50 -070094 static jfieldID java_lang_reflect_AbstractMethod_artMethod;
95 static jfieldID java_lang_reflect_Field_artField;
Elliott Hugheseac76672012-05-24 21:56:51 -070096 static jfieldID java_lang_reflect_Proxy_h;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -070097 static jfieldID java_lang_Thread_daemon;
98 static jfieldID java_lang_Thread_group;
99 static jfieldID java_lang_Thread_lock;
100 static jfieldID java_lang_Thread_name;
101 static jfieldID java_lang_Thread_priority;
102 static jfieldID java_lang_Thread_uncaughtHandler;
Anwar Ghuloum3c50a4b2013-06-21 13:05:23 -0700103 static jfieldID java_lang_Thread_nativePeer;
Elliott Hughesaf8d15a2012-05-29 09:12:18 -0700104 static jfieldID java_lang_ThreadGroup_mainThreadGroup;
105 static jfieldID java_lang_ThreadGroup_name;
106 static jfieldID java_lang_ThreadGroup_systemThreadGroup;
Elliott Hughesaecb5f32013-03-28 08:27:38 -0700107 static jfieldID java_nio_DirectByteBuffer_capacity;
108 static jfieldID java_nio_DirectByteBuffer_effectiveDirectAddress;
Elliott Hugheseac76672012-05-24 21:56:51 -0700109 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_data;
110 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_length;
111 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_offset;
112 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_type;
113};
114
115} // namespace art
116
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700117#endif // ART_RUNTIME_WELL_KNOWN_CLASSES_H_