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 * java.lang.Object
19 */
20 #include "Dalvik.h"
21 #include "native/InternalNativePriv.h"
22
23
24 /*
25 * private Object internalClone()
26 *
27 * Implements most of Object.clone().
28 */
Dalvik_java_lang_Object_internalClone(const u4 * args,JValue * pResult)29 static void Dalvik_java_lang_Object_internalClone(const u4* args,
30 JValue* pResult)
31 {
32 Object* thisPtr = (Object*) args[0];
33 Object* clone = dvmCloneObject(thisPtr, ALLOC_DONT_TRACK);
34
35 RETURN_PTR(clone);
36 }
37
38 /*
39 * public int hashCode()
40 */
Dalvik_java_lang_Object_hashCode(const u4 * args,JValue * pResult)41 static void Dalvik_java_lang_Object_hashCode(const u4* args, JValue* pResult)
42 {
43 Object* thisPtr = (Object*) args[0];
44 RETURN_INT(dvmIdentityHashCode(thisPtr));
45 }
46
47 /*
48 * public Class getClass()
49 */
Dalvik_java_lang_Object_getClass(const u4 * args,JValue * pResult)50 static void Dalvik_java_lang_Object_getClass(const u4* args, JValue* pResult)
51 {
52 Object* thisPtr = (Object*) args[0];
53
54 RETURN_PTR(thisPtr->clazz);
55 }
56
57 /*
58 * public void notify()
59 *
60 * NOTE: we declare this as a full DalvikBridgeFunc, rather than a
61 * DalvikNativeFunc, because we really want to avoid the "self" lookup.
62 */
Dalvik_java_lang_Object_notify(const u4 * args,JValue * pResult,const Method * method,Thread * self)63 static void Dalvik_java_lang_Object_notify(const u4* args, JValue* pResult,
64 const Method* method, Thread* self)
65 {
66 Object* thisPtr = (Object*) args[0];
67
68 dvmObjectNotify(self, thisPtr);
69 RETURN_VOID();
70 }
71
72 /*
73 * public void notifyAll()
74 */
Dalvik_java_lang_Object_notifyAll(const u4 * args,JValue * pResult,const Method * method,Thread * self)75 static void Dalvik_java_lang_Object_notifyAll(const u4* args, JValue* pResult,
76 const Method* method, Thread* self)
77 {
78 Object* thisPtr = (Object*) args[0];
79
80 dvmObjectNotifyAll(self, thisPtr);
81 RETURN_VOID();
82 }
83
84 /*
85 * public void wait(long ms, int ns) throws InterruptedException
86 */
Dalvik_java_lang_Object_wait(const u4 * args,JValue * pResult,const Method * method,Thread * self)87 static void Dalvik_java_lang_Object_wait(const u4* args, JValue* pResult,
88 const Method* method, Thread* self)
89 {
90 Object* thisPtr = (Object*) args[0];
91
92 dvmObjectWait(self, thisPtr, GET_ARG_LONG(args,1), (s4)args[3], true);
93 RETURN_VOID();
94 }
95
96 const DalvikNativeMethod dvm_java_lang_Object[] = {
97 { "internalClone", "(Ljava/lang/Cloneable;)Ljava/lang/Object;",
98 Dalvik_java_lang_Object_internalClone },
99 { "hashCode", "()I",
100 Dalvik_java_lang_Object_hashCode },
101 { "notify", "()V",
102 (DalvikNativeFunc) Dalvik_java_lang_Object_notify },
103 { "notifyAll", "()V",
104 (DalvikNativeFunc) Dalvik_java_lang_Object_notifyAll },
105 { "wait", "(JI)V",
106 (DalvikNativeFunc) Dalvik_java_lang_Object_wait },
107 { "getClass", "()Ljava/lang/Class;",
108 Dalvik_java_lang_Object_getClass },
109 { NULL, NULL, NULL },
110 };
111