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