blob: 41ff8b235d373a2e93dfb16dd2a8954f094a0a8e [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
24namespace {
25
26jclass Object_getClass(JNIEnv* env, jobject javaThis) {
27 // TODO: we can just share the Object::class_ field with Java and use field access instead.
28 Object* o = Decode<Object*>(env, javaThis);
29 return AddLocalReference<jclass>(env, o->GetClass());
30}
31
32jobject Object_internalClone(JNIEnv* env, jobject javaThis) {
33 Object* o = Decode<Object*>(env, javaThis);
34 return AddLocalReference<jobject>(env, o->Clone());
35}
36
37void Object_notify(JNIEnv* env, jobject javaThis) {
38 Object* o = Decode<Object*>(env, javaThis);
39 o->Notify();
40}
41
42void Object_notifyAll(JNIEnv* env, jobject javaThis) {
43 Object* o = Decode<Object*>(env, javaThis);
44 o->NotifyAll();
45}
46
47void Object_wait(JNIEnv* env, jobject javaThis, jlong ms, jint ns) {
48 Object* o = Decode<Object*>(env, javaThis);
49 o->Wait(ms, ns);
50}
51
52JNINativeMethod gMethods[] = {
53 NATIVE_METHOD(Object, getClass, "()Ljava/lang/Class;"),
54 NATIVE_METHOD(Object, internalClone, "(Ljava/lang/Cloneable;)Ljava/lang/Object;"),
55 NATIVE_METHOD(Object, notify, "()V"),
56 NATIVE_METHOD(Object, notifyAll, "()V"),
57 NATIVE_METHOD(Object, wait, "(JI)V"),
58};
59
60} // namespace
61
62void register_java_lang_Object(JNIEnv* env) {
63 jniRegisterNativeMethods(env, "java/lang/Object", gMethods, NELEM(gMethods));
64}
65
66} // namespace art