• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 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 /*
18  * Declarations and definitions common to internal native code.
19  */
20 #ifndef _DALVIK_NATIVE_INTERNALNATIVEPRIV
21 #define _DALVIK_NATIVE_INTERNALNATIVEPRIV
22 
23 /*
24  * Return macros.  Note we use "->i" instead of "->z" for boolean; this
25  * is because the interpreter expects everything to be a 32-bit value.
26  */
27 #ifdef NDEBUG
28 # define RETURN_VOID()           do { (void)(pResult); return; } while(0)
29 #else
30 # define RETURN_VOID()           do { pResult->i = 0xfefeabab; return; }while(0)
31 #endif
32 #define RETURN_BOOLEAN(_val)    do { pResult->i = (_val); return; } while(0)
33 #define RETURN_INT(_val)        do { pResult->i = (_val); return; } while(0)
34 #define RETURN_LONG(_val)       do { pResult->j = (_val); return; } while(0)
35 #define RETURN_FLOAT(_val)      do { pResult->f = (_val); return; } while(0)
36 #define RETURN_DOUBLE(_val)     do { pResult->d = (_val); return; } while(0)
37 #define RETURN_PTR(_val)        do { pResult->l = (_val); return; } while(0)
38 
39 
40 /*
41  * Verify that "obj" is non-null and is an instance of "clazz".
42  *
43  * Returns "false" and throws an exception if not.
44  */
45 bool dvmVerifyObjectInClass(Object* obj, ClassObject* clazz);
46 
47 /*
48  * Find a class by name, initializing it if requested.
49  */
50 ClassObject* dvmFindClassByName(StringObject* nameObj, Object* loader,
51     bool doInit);
52 
53 /*
54  * We insert native method stubs for abstract methods so we don't have to
55  * check the access flags at the time of the method call.  This results in
56  * "native abstract" methods, which can't exist.  If we see the "abstract"
57  * flag set, clear the "native" flag.
58  *
59  * We also move the DECLARED_SYNCHRONIZED flag into the SYNCHRONIZED
60  * position, because the callers of this function are trying to convey
61  * the "traditional" meaning of the flags to their callers.
62  */
63 u4 dvmFixMethodFlags(u4 flags);
64 
65 /*
66  * dvmHashTableFree callback for some DexFile operations.
67  */
68 void dvmFreeDexOrJar(void* vptr);
69 
70 /*
71  * Determine if "method" is a "privileged" invocation, i.e. is it one
72  * of the variations of AccessController.doPrivileged().
73  *
74  * Because the security stuff pulls in a pile of stuff that we may not
75  * want or need, we don't do the class/method lookups at init time, but
76  * instead on first use.
77  */
78 bool dvmIsPrivilegedMethod(const Method* method);
79 
80 
81 /*
82  * Tables of methods.
83  */
84 extern const DalvikNativeMethod dvm_java_lang_Object[];
85 extern const DalvikNativeMethod dvm_java_lang_Class[];
86 extern const DalvikNativeMethod dvm_java_lang_Runtime[];
87 extern const DalvikNativeMethod dvm_java_lang_String[];
88 extern const DalvikNativeMethod dvm_java_lang_System[];
89 extern const DalvikNativeMethod dvm_java_lang_SystemProperties[];
90 extern const DalvikNativeMethod dvm_java_lang_Throwable[];
91 extern const DalvikNativeMethod dvm_java_lang_VMClassLoader[];
92 extern const DalvikNativeMethod dvm_java_lang_VMThread[];
93 extern const DalvikNativeMethod dvm_java_lang_reflect_AccessibleObject[];
94 extern const DalvikNativeMethod dvm_java_lang_reflect_Array[];
95 extern const DalvikNativeMethod dvm_java_lang_reflect_Constructor[];
96 extern const DalvikNativeMethod dvm_java_lang_reflect_Field[];
97 extern const DalvikNativeMethod dvm_java_lang_reflect_Method[];
98 extern const DalvikNativeMethod dvm_java_lang_reflect_Proxy[];
99 extern const DalvikNativeMethod dvm_java_security_AccessController[];
100 extern const DalvikNativeMethod dvm_java_util_concurrent_atomic_AtomicLong[];
101 extern const DalvikNativeMethod dvm_dalvik_system_SamplingProfiler[];
102 extern const DalvikNativeMethod dvm_dalvik_system_VMDebug[];
103 extern const DalvikNativeMethod dvm_dalvik_system_DexFile[];
104 extern const DalvikNativeMethod dvm_dalvik_system_VMRuntime[];
105 extern const DalvikNativeMethod dvm_dalvik_system_Zygote[];
106 extern const DalvikNativeMethod dvm_dalvik_system_VMStack[];
107 extern const DalvikNativeMethod dvm_org_apache_harmony_dalvik_ddmc_DdmServer[];
108 extern const DalvikNativeMethod dvm_org_apache_harmony_dalvik_ddmc_DdmVmInternal[];
109 extern const DalvikNativeMethod dvm_org_apache_harmony_dalvik_NativeTestTarget[];
110 extern const DalvikNativeMethod dvm_sun_misc_Unsafe[];
111 
112 #endif /*_DALVIK_NATIVE_INTERNALNATIVEPRIV*/
113