Home | History | Annotate | Download | only in native
      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 
     24 namespace art {
     25 
     26 static jobject Object_internalClone(JNIEnv* env, jobject java_this) {
     27   ScopedFastNativeObjectAccess soa(env);
     28   mirror::Object* o = soa.Decode<mirror::Object*>(java_this);
     29   return soa.AddLocalReference<jobject>(o->Clone(soa.Self()));
     30 }
     31 
     32 static void Object_notify(JNIEnv* env, jobject java_this) {
     33   ScopedFastNativeObjectAccess soa(env);
     34   mirror::Object* o = soa.Decode<mirror::Object*>(java_this);
     35   o->Notify(soa.Self());
     36 }
     37 
     38 static void Object_notifyAll(JNIEnv* env, jobject java_this) {
     39   ScopedFastNativeObjectAccess soa(env);
     40   mirror::Object* o = soa.Decode<mirror::Object*>(java_this);
     41   o->NotifyAll(soa.Self());
     42 }
     43 
     44 static void Object_wait(JNIEnv* env, jobject java_this) {
     45   ScopedFastNativeObjectAccess soa(env);
     46   mirror::Object* o = soa.Decode<mirror::Object*>(java_this);
     47   o->Wait(soa.Self());
     48 }
     49 
     50 static void Object_waitJI(JNIEnv* env, jobject java_this, jlong ms, jint ns) {
     51   ScopedFastNativeObjectAccess soa(env);
     52   mirror::Object* o = soa.Decode<mirror::Object*>(java_this);
     53   o->Wait(soa.Self(), ms, ns);
     54 }
     55 
     56 static JNINativeMethod gMethods[] = {
     57   NATIVE_METHOD(Object, internalClone, "!()Ljava/lang/Object;"),
     58   NATIVE_METHOD(Object, notify, "!()V"),
     59   NATIVE_METHOD(Object, notifyAll, "!()V"),
     60   OVERLOADED_NATIVE_METHOD(Object, wait, "!()V", wait),
     61   OVERLOADED_NATIVE_METHOD(Object, wait, "!(JI)V", waitJI),
     62 };
     63 
     64 void register_java_lang_Object(JNIEnv* env) {
     65   REGISTER_NATIVE_METHODS("java/lang/Object");
     66 }
     67 
     68 }  // namespace art
     69