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 "jni_internal.h"
20#include "mirror/object-inl.h"
21#include "scoped_fast_native_object_access.h"
22
23// TODO: better support for overloading.
24#undef NATIVE_METHOD
25#define NATIVE_METHOD(className, functionName, signature, identifier) \
26    { #functionName, signature, reinterpret_cast<void*>(className ## _ ## identifier) }
27
28namespace art {
29
30static jobject Object_internalClone(JNIEnv* env, jobject java_this) {
31  ScopedFastNativeObjectAccess soa(env);
32  mirror::Object* o = soa.Decode<mirror::Object*>(java_this);
33  return soa.AddLocalReference<jobject>(o->Clone(soa.Self()));
34}
35
36static void Object_notify(JNIEnv* env, jobject java_this) {
37  ScopedFastNativeObjectAccess soa(env);
38  mirror::Object* o = soa.Decode<mirror::Object*>(java_this);
39  o->Notify(soa.Self());
40}
41
42static void Object_notifyAll(JNIEnv* env, jobject java_this) {
43  ScopedFastNativeObjectAccess soa(env);
44  mirror::Object* o = soa.Decode<mirror::Object*>(java_this);
45  o->NotifyAll(soa.Self());
46}
47
48static void Object_wait(JNIEnv* env, jobject java_this) {
49  ScopedFastNativeObjectAccess soa(env);
50  mirror::Object* o = soa.Decode<mirror::Object*>(java_this);
51  o->Wait(soa.Self());
52}
53
54static void Object_waitJI(JNIEnv* env, jobject java_this, jlong ms, jint ns) {
55  ScopedFastNativeObjectAccess soa(env);
56  mirror::Object* o = soa.Decode<mirror::Object*>(java_this);
57  o->Wait(soa.Self(), ms, ns);
58}
59
60static JNINativeMethod gMethods[] = {
61  NATIVE_METHOD(Object, internalClone, "!()Ljava/lang/Object;", internalClone),
62  NATIVE_METHOD(Object, notify, "!()V", notify),
63  NATIVE_METHOD(Object, notifyAll, "!()V", notifyAll),
64  NATIVE_METHOD(Object, wait, "!()V", wait),
65  NATIVE_METHOD(Object, wait, "!(JI)V", waitJI),
66};
67
68void register_java_lang_Object(JNIEnv* env) {
69  REGISTER_NATIVE_METHODS("java/lang/Object");
70}
71
72}  // namespace art
73