• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_RUNTIME_WELL_KNOWN_CLASSES_H_
18 #define ART_RUNTIME_WELL_KNOWN_CLASSES_H_
19 
20 #include "base/locks.h"
21 #include "jni.h"
22 #include "obj_ptr.h"
23 
24 namespace art {
25 
26 class ArtMethod;
27 
28 namespace mirror {
29 class Class;
30 }  // namespace mirror
31 
32 // Various classes used in JNI. We cache them so we don't have to keep looking them up.
33 
34 struct WellKnownClasses {
35  public:
36   // Run before native methods are registered.
37   static void Init(JNIEnv* env);
38   // Run after native methods are registered.
39   static void LateInit(JNIEnv* env);
40 
41   static void Clear();
42 
43   static void HandleJniIdTypeChange(JNIEnv* env);
44 
45   static void InitStringInit(ObjPtr<mirror::Class> string_class,
46                              ObjPtr<mirror::Class> string_builder_class)
47       REQUIRES_SHARED(Locks::mutator_lock_);
48   static ArtMethod* StringInitToStringFactory(ArtMethod* method);
49   static uint32_t StringInitToEntryPoint(ArtMethod* method);
50 
51   static ObjPtr<mirror::Class> ToClass(jclass global_jclass) REQUIRES_SHARED(Locks::mutator_lock_);
52 
53  private:
54   static void InitFieldsAndMethodsOnly(JNIEnv* env);
55 
56  public:
57   static jclass dalvik_annotation_optimization_CriticalNative;
58   static jclass dalvik_annotation_optimization_FastNative;
59   static jclass dalvik_system_BaseDexClassLoader;
60   static jclass dalvik_system_DelegateLastClassLoader;
61   static jclass dalvik_system_DexClassLoader;
62   static jclass dalvik_system_DexFile;
63   static jclass dalvik_system_DexPathList;
64   static jclass dalvik_system_DexPathList__Element;
65   static jclass dalvik_system_EmulatedStackFrame;
66   static jclass dalvik_system_InMemoryDexClassLoader;
67   static jclass dalvik_system_PathClassLoader;
68   static jclass dalvik_system_VMRuntime;
69   static jclass java_lang_annotation_Annotation__array;
70   static jclass java_lang_BootClassLoader;
71   static jclass java_lang_ClassLoader;
72   static jclass java_lang_ClassNotFoundException;
73   static jclass java_lang_Daemons;
74   static jclass java_lang_Error;
75   static jclass java_lang_IllegalAccessError;
76   static jclass java_lang_NoClassDefFoundError;
77   static jclass java_lang_Object;
78   static jclass java_lang_OutOfMemoryError;
79   static jclass java_lang_reflect_InvocationTargetException;
80   static jclass java_lang_reflect_Parameter;
81   static jclass java_lang_reflect_Parameter__array;
82   static jclass java_lang_reflect_Proxy;
83   static jclass java_lang_RuntimeException;
84   static jclass java_lang_StackOverflowError;
85   static jclass java_lang_String;
86   static jclass java_lang_StringFactory;
87   static jclass java_lang_System;
88   static jclass java_lang_Thread;
89   static jclass java_lang_ThreadGroup;
90   static jclass java_lang_Throwable;
91   static jclass java_nio_ByteBuffer;
92   static jclass java_nio_DirectByteBuffer;
93   static jclass java_util_Collections;
94   static jclass java_util_function_Consumer;
95   static jclass libcore_reflect_AnnotationFactory;
96   static jclass libcore_reflect_AnnotationMember;
97   static jclass libcore_util_EmptyArray;
98   static jclass org_apache_harmony_dalvik_ddmc_Chunk;
99   static jclass org_apache_harmony_dalvik_ddmc_DdmServer;
100 
101   static jmethodID dalvik_system_BaseDexClassLoader_getLdLibraryPath;
102   static jmethodID dalvik_system_VMRuntime_runFinalization;
103   static jmethodID dalvik_system_VMRuntime_hiddenApiUsed;
104   static jmethodID java_lang_Boolean_valueOf;
105   static jmethodID java_lang_Byte_valueOf;
106   static jmethodID java_lang_Character_valueOf;
107   static jmethodID java_lang_ClassLoader_loadClass;
108   static jmethodID java_lang_ClassNotFoundException_init;
109   static jmethodID java_lang_Daemons_start;
110   static jmethodID java_lang_Daemons_stop;
111   static jmethodID java_lang_Daemons_waitForDaemonStart;
112   static jmethodID java_lang_Double_valueOf;
113   static jmethodID java_lang_Float_valueOf;
114   static jmethodID java_lang_Integer_valueOf;
115   static jmethodID java_lang_invoke_MethodHandles_lookup;
116   static jmethodID java_lang_invoke_MethodHandles_Lookup_findConstructor;
117   static jmethodID java_lang_Long_valueOf;
118   static jmethodID java_lang_ref_FinalizerReference_add;
119   static jmethodID java_lang_ref_ReferenceQueue_add;
120   static jmethodID java_lang_reflect_InvocationTargetException_init;
121   static jmethodID java_lang_reflect_Parameter_init;
122   static jmethodID java_lang_reflect_Proxy_init;
123   static jmethodID java_lang_reflect_Proxy_invoke;
124   static jmethodID java_lang_Runtime_nativeLoad;
125   static jmethodID java_lang_Short_valueOf;
126   static jmethodID java_lang_String_charAt;
127   static jmethodID java_lang_Thread_dispatchUncaughtException;
128   static jmethodID java_lang_Thread_init;
129   static jmethodID java_lang_Thread_run;
130   static jmethodID java_lang_ThreadGroup_add;
131   static jmethodID java_lang_ThreadGroup_removeThread;
132   static jmethodID java_nio_DirectByteBuffer_init;
133   static jmethodID java_util_function_Consumer_accept;
134   static jmethodID libcore_reflect_AnnotationFactory_createAnnotation;
135   static jmethodID libcore_reflect_AnnotationMember_init;
136   static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast;
137   static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch;
138 
139   static jfieldID dalvik_system_BaseDexClassLoader_pathList;
140   static jfieldID dalvik_system_BaseDexClassLoader_sharedLibraryLoaders;
141   static jfieldID dalvik_system_DexFile_cookie;
142   static jfieldID dalvik_system_DexFile_fileName;
143   static jfieldID dalvik_system_DexPathList_dexElements;
144   static jfieldID dalvik_system_DexPathList__Element_dexFile;
145   static jfieldID dalvik_system_VMRuntime_nonSdkApiUsageConsumer;
146   static jfieldID java_io_FileDescriptor_descriptor;
147   static jfieldID java_io_FileDescriptor_ownerId;
148   static jfieldID java_lang_Thread_parkBlocker;
149   static jfieldID java_lang_Thread_daemon;
150   static jfieldID java_lang_Thread_group;
151   static jfieldID java_lang_Thread_lock;
152   static jfieldID java_lang_Thread_name;
153   static jfieldID java_lang_Thread_priority;
154   static jfieldID java_lang_Thread_nativePeer;
155   static jfieldID java_lang_Thread_systemDaemon;
156   static jfieldID java_lang_Thread_unparkedBeforeStart;
157   static jfieldID java_lang_ThreadGroup_groups;
158   static jfieldID java_lang_ThreadGroup_ngroups;
159   static jfieldID java_lang_ThreadGroup_mainThreadGroup;
160   static jfieldID java_lang_ThreadGroup_name;
161   static jfieldID java_lang_ThreadGroup_parent;
162   static jfieldID java_lang_ThreadGroup_systemThreadGroup;
163   static jfieldID java_lang_Throwable_cause;
164   static jfieldID java_lang_Throwable_detailMessage;
165   static jfieldID java_lang_Throwable_stackTrace;
166   static jfieldID java_lang_Throwable_stackState;
167   static jfieldID java_lang_Throwable_suppressedExceptions;
168   static jfieldID java_nio_Buffer_address;
169   static jfieldID java_nio_Buffer_elementSizeShift;
170   static jfieldID java_nio_Buffer_limit;
171   static jfieldID java_nio_Buffer_position;
172   static jfieldID java_nio_ByteBuffer_address;
173   static jfieldID java_nio_ByteBuffer_hb;
174   static jfieldID java_nio_ByteBuffer_isReadOnly;
175   static jfieldID java_nio_ByteBuffer_limit;
176   static jfieldID java_nio_ByteBuffer_offset;
177   static jfieldID java_nio_DirectByteBuffer_capacity;
178   static jfieldID java_nio_DirectByteBuffer_effectiveDirectAddress;
179 
180   static jfieldID java_util_Collections_EMPTY_LIST;
181   static jfieldID libcore_util_EmptyArray_STACK_TRACE_ELEMENT;
182   static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_data;
183   static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_length;
184   static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_offset;
185   static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_type;
186 };
187 
188 }  // namespace art
189 
190 #endif  // ART_RUNTIME_WELL_KNOWN_CLASSES_H_
191