blob: 51e4581de04cd93d6efc9748fb80fcc09dc4b2c0 [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
Elliott Hughesbf86d042011-08-31 17:53:14 -070020namespace art {
21
Elliott Hughes0512f022012-03-15 22:10:52 -070022static jobject Object_internalClone(JNIEnv* env, jobject javaThis) {
Elliott Hughes34e06962012-04-09 13:55:55 -070023 ScopedThreadStateChange tsc(Thread::Current(), kRunnable);
Elliott Hughesbf86d042011-08-31 17:53:14 -070024 Object* o = Decode<Object*>(env, javaThis);
25 return AddLocalReference<jobject>(env, o->Clone());
26}
27
Elliott Hughes0512f022012-03-15 22:10:52 -070028static void Object_notify(JNIEnv* env, jobject javaThis) {
Elliott Hughesbf86d042011-08-31 17:53:14 -070029 Object* o = Decode<Object*>(env, javaThis);
30 o->Notify();
31}
32
Elliott Hughes0512f022012-03-15 22:10:52 -070033static void Object_notifyAll(JNIEnv* env, jobject javaThis) {
Elliott Hughesbf86d042011-08-31 17:53:14 -070034 Object* o = Decode<Object*>(env, javaThis);
35 o->NotifyAll();
36}
37
Elliott Hughes0512f022012-03-15 22:10:52 -070038static void Object_wait(JNIEnv* env, jobject javaThis, jlong ms, jint ns) {
Elliott Hughesbf86d042011-08-31 17:53:14 -070039 Object* o = Decode<Object*>(env, javaThis);
40 o->Wait(ms, ns);
41}
42
Elliott Hughes0512f022012-03-15 22:10:52 -070043static JNINativeMethod gMethods[] = {
Elliott Hughesbf86d042011-08-31 17:53:14 -070044 NATIVE_METHOD(Object, internalClone, "(Ljava/lang/Cloneable;)Ljava/lang/Object;"),
45 NATIVE_METHOD(Object, notify, "()V"),
46 NATIVE_METHOD(Object, notifyAll, "()V"),
47 NATIVE_METHOD(Object, wait, "(JI)V"),
48};
49
Elliott Hughesbf86d042011-08-31 17:53:14 -070050void register_java_lang_Object(JNIEnv* env) {
Elliott Hugheseac76672012-05-24 21:56:51 -070051 REGISTER_NATIVE_METHODS("java/lang/Object");
Elliott Hughesbf86d042011-08-31 17:53:14 -070052}
53
54} // namespace art