Elliott Hughes | bf86d04 | 2011-08-31 17:53:14 -0700 | [diff] [blame] | 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 "object.h" |
| 19 | |
| 20 | #include "JniConstants.h" // Last to avoid problems with LOG redefinition. |
| 21 | |
| 22 | namespace art { |
| 23 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 24 | static jobject Object_internalClone(JNIEnv* env, jobject javaThis) { |
Brian Carlstrom | b82b687 | 2011-10-26 17:18:07 -0700 | [diff] [blame] | 25 | ScopedThreadStateChange tsc(Thread::Current(), Thread::kRunnable); |
Elliott Hughes | bf86d04 | 2011-08-31 17:53:14 -0700 | [diff] [blame] | 26 | Object* o = Decode<Object*>(env, javaThis); |
| 27 | return AddLocalReference<jobject>(env, o->Clone()); |
| 28 | } |
| 29 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 30 | static void Object_notify(JNIEnv* env, jobject javaThis) { |
Elliott Hughes | bf86d04 | 2011-08-31 17:53:14 -0700 | [diff] [blame] | 31 | Object* o = Decode<Object*>(env, javaThis); |
| 32 | o->Notify(); |
| 33 | } |
| 34 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 35 | static void Object_notifyAll(JNIEnv* env, jobject javaThis) { |
Elliott Hughes | bf86d04 | 2011-08-31 17:53:14 -0700 | [diff] [blame] | 36 | Object* o = Decode<Object*>(env, javaThis); |
| 37 | o->NotifyAll(); |
| 38 | } |
| 39 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 40 | static void Object_wait(JNIEnv* env, jobject javaThis, jlong ms, jint ns) { |
Elliott Hughes | bf86d04 | 2011-08-31 17:53:14 -0700 | [diff] [blame] | 41 | Object* o = Decode<Object*>(env, javaThis); |
| 42 | o->Wait(ms, ns); |
| 43 | } |
| 44 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 45 | static JNINativeMethod gMethods[] = { |
Elliott Hughes | bf86d04 | 2011-08-31 17:53:14 -0700 | [diff] [blame] | 46 | NATIVE_METHOD(Object, internalClone, "(Ljava/lang/Cloneable;)Ljava/lang/Object;"), |
| 47 | NATIVE_METHOD(Object, notify, "()V"), |
| 48 | NATIVE_METHOD(Object, notifyAll, "()V"), |
| 49 | NATIVE_METHOD(Object, wait, "(JI)V"), |
| 50 | }; |
| 51 | |
Elliott Hughes | bf86d04 | 2011-08-31 17:53:14 -0700 | [diff] [blame] | 52 | void register_java_lang_Object(JNIEnv* env) { |
| 53 | jniRegisterNativeMethods(env, "java/lang/Object", gMethods, NELEM(gMethods)); |
| 54 | } |
| 55 | |
| 56 | } // namespace art |