Home | History | Annotate | Download | only in runtime
      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/mutex.h"
     21 #include "jni.h"
     22 
     23 namespace art {
     24 namespace mirror {
     25 class Class;
     26 }  // namespace mirror
     27 
     28 // 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 
     32 jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, const char* name, const char* signature);
     33 
     34 struct WellKnownClasses {
     35  public:
     36   static void Init(JNIEnv* env);  // Run before native methods are registered.
     37   static void LateInit(JNIEnv* env);  // Run after native methods are registered.
     38 
     39   static mirror::Class* ToClass(jclass global_jclass)
     40       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
     41 
     42   static jclass com_android_dex_Dex;
     43   static jclass dalvik_system_DexFile;
     44   static jclass dalvik_system_DexPathList;
     45   static jclass dalvik_system_DexPathList$Element;
     46   static jclass dalvik_system_PathClassLoader;
     47   static jclass java_lang_BootClassLoader;
     48   static jclass java_lang_ClassLoader;
     49   static jclass java_lang_ClassNotFoundException;
     50   static jclass java_lang_Daemons;
     51   static jclass java_lang_Error;
     52   static jclass java_lang_Object;
     53   static jclass java_lang_reflect_AbstractMethod;
     54   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;
     58   static jclass java_lang_reflect_Proxy;
     59   static jclass java_lang_RuntimeException;
     60   static jclass java_lang_StackOverflowError;
     61   static jclass java_lang_String;
     62   static jclass java_lang_System;
     63   static jclass java_lang_Thread;
     64   static jclass java_lang_ThreadGroup;
     65   static jclass java_lang_Thread$UncaughtExceptionHandler;
     66   static jclass java_lang_Throwable;
     67   static jclass java_util_Collections;
     68   static jclass java_nio_DirectByteBuffer;
     69   static jclass libcore_util_EmptyArray;
     70   static jclass org_apache_harmony_dalvik_ddmc_Chunk;
     71   static jclass org_apache_harmony_dalvik_ddmc_DdmServer;
     72 
     73   static jmethodID com_android_dex_Dex_create;
     74   static jmethodID java_lang_Boolean_valueOf;
     75   static jmethodID java_lang_Byte_valueOf;
     76   static jmethodID java_lang_Character_valueOf;
     77   static jmethodID java_lang_ClassLoader_loadClass;
     78   static jmethodID java_lang_ClassNotFoundException_init;
     79   static jmethodID java_lang_Daemons_requestGC;
     80   static jmethodID java_lang_Daemons_requestHeapTrim;
     81   static jmethodID java_lang_Daemons_start;
     82   static jmethodID java_lang_Double_valueOf;
     83   static jmethodID java_lang_Float_valueOf;
     84   static jmethodID java_lang_Integer_valueOf;
     85   static jmethodID java_lang_Long_valueOf;
     86   static jmethodID java_lang_ref_FinalizerReference_add;
     87   static jmethodID java_lang_ref_ReferenceQueue_add;
     88   static jmethodID java_lang_reflect_Proxy_invoke;
     89   static jmethodID java_lang_Runtime_nativeLoad;
     90   static jmethodID java_lang_Short_valueOf;
     91   static jmethodID java_lang_System_runFinalization;
     92   static jmethodID java_lang_Thread_init;
     93   static jmethodID java_lang_Thread_run;
     94   static jmethodID java_lang_Thread$UncaughtExceptionHandler_uncaughtException;
     95   static jmethodID java_lang_ThreadGroup_removeThread;
     96   static jmethodID java_nio_DirectByteBuffer_init;
     97   static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast;
     98   static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch;
     99 
    100   static jfieldID dalvik_system_DexFile_cookie;
    101   static jfieldID dalvik_system_DexPathList_dexElements;
    102   static jfieldID dalvik_system_DexPathList$Element_dexFile;
    103   static jfieldID dalvik_system_PathClassLoader_pathList;
    104   static jfieldID java_lang_reflect_AbstractMethod_artMethod;
    105   static jfieldID java_lang_reflect_Field_artField;
    106   static jfieldID java_lang_reflect_Proxy_h;
    107   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;
    113   static jfieldID java_lang_Thread_nativePeer;
    114   static jfieldID java_lang_ThreadGroup_mainThreadGroup;
    115   static jfieldID java_lang_ThreadGroup_name;
    116   static jfieldID java_lang_ThreadGroup_systemThreadGroup;
    117   static jfieldID java_lang_Throwable_cause;
    118   static jfieldID java_lang_Throwable_detailMessage;
    119   static jfieldID java_lang_Throwable_stackTrace;
    120   static jfieldID java_lang_Throwable_stackState;
    121   static jfieldID java_lang_Throwable_suppressedExceptions;
    122   static jfieldID java_nio_DirectByteBuffer_capacity;
    123   static jfieldID java_nio_DirectByteBuffer_effectiveDirectAddress;
    124   static jfieldID java_util_Collections_EMPTY_LIST;
    125   static jfieldID libcore_util_EmptyArray_STACK_TRACE_ELEMENT;
    126   static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_data;
    127   static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_length;
    128   static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_offset;
    129   static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_type;
    130 };
    131 
    132 }  // namespace art
    133 
    134 #endif  // ART_RUNTIME_WELL_KNOWN_CLASSES_H_
    135