blob: f95d1a1518d8269ebd5bdbaf902594dd8e78b8c9 [file] [log] [blame]
Elliott Hughesbf86d042011-08-31 17:53:14 -07001/*
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
22namespace art {
23
Elliott Hughes0512f022012-03-15 22:10:52 -070024static jobject Object_internalClone(JNIEnv* env, jobject javaThis) {
Brian Carlstromb82b6872011-10-26 17:18:07 -070025 ScopedThreadStateChange tsc(Thread::Current(), Thread::kRunnable);
Elliott Hughesbf86d042011-08-31 17:53:14 -070026 Object* o = Decode<Object*>(env, javaThis);
27 return AddLocalReference<jobject>(env, o->Clone());
28}
29
Elliott Hughes0512f022012-03-15 22:10:52 -070030static void Object_notify(JNIEnv* env, jobject javaThis) {
Elliott Hughesbf86d042011-08-31 17:53:14 -070031 Object* o = Decode<Object*>(env, javaThis);
32 o->Notify();
33}
34
Elliott Hughes0512f022012-03-15 22:10:52 -070035static void Object_notifyAll(JNIEnv* env, jobject javaThis) {
Elliott Hughesbf86d042011-08-31 17:53:14 -070036 Object* o = Decode<Object*>(env, javaThis);
37 o->NotifyAll();
38}
39
Elliott Hughes0512f022012-03-15 22:10:52 -070040static void Object_wait(JNIEnv* env, jobject javaThis, jlong ms, jint ns) {
Elliott Hughesbf86d042011-08-31 17:53:14 -070041 Object* o = Decode<Object*>(env, javaThis);
42 o->Wait(ms, ns);
43}
44
Elliott Hughes0512f022012-03-15 22:10:52 -070045static JNINativeMethod gMethods[] = {
Elliott Hughesbf86d042011-08-31 17:53:14 -070046 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 Hughesbf86d042011-08-31 17:53:14 -070052void register_java_lang_Object(JNIEnv* env) {
53 jniRegisterNativeMethods(env, "java/lang/Object", gMethods, NELEM(gMethods));
54}
55
56} // namespace art