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