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 #include "java_lang_Object.h"
18
19 #include "nativehelper/jni_macros.h"
20
21 #include "jni_internal.h"
22 #include "mirror/object-inl.h"
23 #include "native_util.h"
24 #include "scoped_fast_native_object_access-inl.h"
25
26 namespace art {
27
Object_internalClone(JNIEnv * env,jobject java_this)28 static jobject Object_internalClone(JNIEnv* env, jobject java_this) {
29 ScopedFastNativeObjectAccess soa(env);
30 ObjPtr<mirror::Object> o = soa.Decode<mirror::Object>(java_this);
31 return soa.AddLocalReference<jobject>(o->Clone(soa.Self()));
32 }
33
Object_notify(JNIEnv * env,jobject java_this)34 static void Object_notify(JNIEnv* env, jobject java_this) {
35 ScopedFastNativeObjectAccess soa(env);
36 soa.Decode<mirror::Object>(java_this)->Notify(soa.Self());
37 }
38
Object_notifyAll(JNIEnv * env,jobject java_this)39 static void Object_notifyAll(JNIEnv* env, jobject java_this) {
40 ScopedFastNativeObjectAccess soa(env);
41 soa.Decode<mirror::Object>(java_this)->NotifyAll(soa.Self());
42 }
43
Object_wait(JNIEnv * env,jobject java_this)44 static void Object_wait(JNIEnv* env, jobject java_this) {
45 ScopedFastNativeObjectAccess soa(env);
46 soa.Decode<mirror::Object>(java_this)->Wait(soa.Self());
47 }
48
Object_waitJI(JNIEnv * env,jobject java_this,jlong ms,jint ns)49 static void Object_waitJI(JNIEnv* env, jobject java_this, jlong ms, jint ns) {
50 ScopedFastNativeObjectAccess soa(env);
51 soa.Decode<mirror::Object>(java_this)->Wait(soa.Self(), ms, ns);
52 }
53
Object_identityHashCodeNative(JNIEnv * env,jclass,jobject javaObject)54 static jint Object_identityHashCodeNative(JNIEnv* env, jclass, jobject javaObject) {
55 ScopedFastNativeObjectAccess soa(env);
56 ObjPtr<mirror::Object> o = soa.Decode<mirror::Object>(javaObject);
57 return static_cast<jint>(o->IdentityHashCode());
58 }
59
60 static JNINativeMethod gMethods[] = {
61 FAST_NATIVE_METHOD(Object, internalClone, "()Ljava/lang/Object;"),
62 FAST_NATIVE_METHOD(Object, notify, "()V"),
63 FAST_NATIVE_METHOD(Object, notifyAll, "()V"),
64 OVERLOADED_FAST_NATIVE_METHOD(Object, wait, "()V", wait),
65 OVERLOADED_FAST_NATIVE_METHOD(Object, wait, "(JI)V", waitJI),
66 FAST_NATIVE_METHOD(Object, identityHashCodeNative, "(Ljava/lang/Object;)I"),
67 };
68
register_java_lang_Object(JNIEnv * env)69 void register_java_lang_Object(JNIEnv* env) {
70 REGISTER_NATIVE_METHODS("java/lang/Object");
71 }
72
73 } // namespace art
74