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