blob: b2ede634b7c16fc704f6dbc3b090cfc8955eb22e [file] [log] [blame]
Brian Carlstromf867b6f2011-09-16 12:17:25 -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
Brian Carlstromf867b6f2011-09-16 12:17:25 -070017#include "class_linker.h"
Elliott Hugheseac76672012-05-24 21:56:51 -070018#include "jni_internal.h"
Brian Carlstromf867b6f2011-09-16 12:17:25 -070019#include "object.h"
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080020#include "object_utils.h"
Elliott Hughes418d20f2011-09-22 14:00:39 -070021#include "reflection.h"
Ian Rogers365c1022012-06-22 15:05:28 -070022#include "scoped_jni_thread_state.h"
Brian Carlstromf867b6f2011-09-16 12:17:25 -070023
Brian Carlstromf867b6f2011-09-16 12:17:25 -070024namespace art {
25
Ian Rogers365c1022012-06-22 15:05:28 -070026static bool GetFieldValue(const ScopedJniThreadState& ts, Object* o, Field* f, JValue& value,
27 bool allow_references) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070028 DCHECK_EQ(value.GetJ(), 0LL);
Ian Rogers0045a292012-03-31 21:08:41 -070029 if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(f->GetDeclaringClass(), true, true)) {
Elliott Hughes923e8b82012-03-23 11:44:07 -070030 return false;
31 }
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080032 switch (FieldHelper(f).GetTypeAsPrimitiveType()) {
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070033 case Primitive::kPrimBoolean:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070034 value.SetZ(f->GetBoolean(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070035 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070036 case Primitive::kPrimByte:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070037 value.SetB(f->GetByte(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070038 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070039 case Primitive::kPrimChar:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070040 value.SetC(f->GetChar(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070041 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070042 case Primitive::kPrimDouble:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070043 value.SetD(f->GetDouble(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070044 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070045 case Primitive::kPrimFloat:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070046 value.SetF(f->GetFloat(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070047 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070048 case Primitive::kPrimInt:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070049 value.SetI(f->GetInt(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070050 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070051 case Primitive::kPrimLong:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070052 value.SetJ(f->GetLong(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070053 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070054 case Primitive::kPrimShort:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070055 value.SetS(f->GetShort(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070056 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070057 case Primitive::kPrimNot:
Elliott Hughes33203b52011-09-20 19:42:01 -070058 if (allow_references) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070059 value.SetL(f->GetObject(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070060 return true;
61 }
62 // Else break to report an error.
63 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070064 case Primitive::kPrimVoid:
Elliott Hughes33203b52011-09-20 19:42:01 -070065 // Never okay.
66 break;
67 }
Ian Rogers365c1022012-06-22 15:05:28 -070068 ts.Self()->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
Elliott Hughes33203b52011-09-20 19:42:01 -070069 "Not a primitive field: %s", PrettyField(f).c_str());
70 return false;
71}
72
Ian Rogers365c1022012-06-22 15:05:28 -070073static bool CheckReceiver(const ScopedJniThreadState& ts, jobject javaObj, Field* f, Object*& o) {
Elliott Hughesed1c1e32011-10-02 14:31:05 -070074 if (f->IsStatic()) {
75 o = NULL;
76 return true;
77 }
78
Ian Rogers365c1022012-06-22 15:05:28 -070079 o = ts.Decode<Object*>(javaObj);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080080 Class* declaringClass = f->GetDeclaringClass();
Elliott Hugheseac76672012-05-24 21:56:51 -070081 if (!VerifyObjectInClass(o, declaringClass)) {
Elliott Hughesed1c1e32011-10-02 14:31:05 -070082 return false;
83 }
84 return true;
85}
86
Elliott Hughes0512f022012-03-15 22:10:52 -070087static jobject Field_get(JNIEnv* env, jobject javaField, jobject javaObj) {
Ian Rogers365c1022012-06-22 15:05:28 -070088 ScopedJniThreadState ts(env);
89 Field* f = ts.DecodeField(env->FromReflectedField(javaField));
Elliott Hughesed1c1e32011-10-02 14:31:05 -070090 Object* o = NULL;
Ian Rogers365c1022012-06-22 15:05:28 -070091 if (!CheckReceiver(ts, javaObj, f, o)) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080092 return NULL;
93 }
94
95 // Get the field's value, boxing if necessary.
Elliott Hughes1d878f32012-04-11 15:17:54 -070096 JValue value;
Ian Rogers365c1022012-06-22 15:05:28 -070097 if (!GetFieldValue(ts, o, f, value, true)) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080098 return NULL;
99 }
Elliott Hughesdbac3092012-03-16 18:00:30 -0700100 BoxPrimitive(FieldHelper(f).GetTypeAsPrimitiveType(), value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800101
Ian Rogers365c1022012-06-22 15:05:28 -0700102 return ts.AddLocalReference<jobject>(value.GetL());
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800103}
104
Elliott Hughes0512f022012-03-15 22:10:52 -0700105static JValue GetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, char dst_descriptor) {
Ian Rogers365c1022012-06-22 15:05:28 -0700106 ScopedJniThreadState ts(env);
107 Field* f = ts.DecodeField(env->FromReflectedField(javaField));
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800108 Object* o = NULL;
Ian Rogers365c1022012-06-22 15:05:28 -0700109 if (!CheckReceiver(ts, javaObj, f, o)) {
Elliott Hughesed1c1e32011-10-02 14:31:05 -0700110 return JValue();
Elliott Hughes33203b52011-09-20 19:42:01 -0700111 }
112
113 // Read the value.
Elliott Hughes1d878f32012-04-11 15:17:54 -0700114 JValue field_value;
Ian Rogers365c1022012-06-22 15:05:28 -0700115 if (!GetFieldValue(ts, o, f, field_value, false)) {
Elliott Hughes33203b52011-09-20 19:42:01 -0700116 return JValue();
117 }
118
119 // Widen it if necessary (and possible).
120 JValue wide_value;
Elliott Hughes582a7d12011-10-10 18:38:42 -0700121 Class* dst_type = Runtime::Current()->GetClassLinker()->FindPrimitiveClass(dst_descriptor);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800122 if (!ConvertPrimitiveValue(FieldHelper(f).GetTypeAsPrimitiveType(), dst_type->GetPrimitiveType(),
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700123 field_value, wide_value)) {
Elliott Hughes33203b52011-09-20 19:42:01 -0700124 return JValue();
125 }
126 return wide_value;
127}
128
Elliott Hughes0512f022012-03-15 22:10:52 -0700129static jboolean Field_getBoolean(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700130 return GetPrimitiveField(env, javaField, javaObj, 'Z').GetZ();
Elliott Hughes33203b52011-09-20 19:42:01 -0700131}
132
Elliott Hughes0512f022012-03-15 22:10:52 -0700133static jbyte Field_getByte(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700134 return GetPrimitiveField(env, javaField, javaObj, 'B').GetB();
Elliott Hughes33203b52011-09-20 19:42:01 -0700135}
136
Elliott Hughes0512f022012-03-15 22:10:52 -0700137static jchar Field_getChar(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700138 return GetPrimitiveField(env, javaField, javaObj, 'C').GetC();
Elliott Hughes33203b52011-09-20 19:42:01 -0700139}
140
Elliott Hughes0512f022012-03-15 22:10:52 -0700141static jdouble Field_getDouble(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700142 return GetPrimitiveField(env, javaField, javaObj, 'D').GetD();
Elliott Hughes33203b52011-09-20 19:42:01 -0700143}
144
Elliott Hughes0512f022012-03-15 22:10:52 -0700145static jfloat Field_getFloat(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700146 return GetPrimitiveField(env, javaField, javaObj, 'F').GetF();
Elliott Hughes33203b52011-09-20 19:42:01 -0700147}
148
Elliott Hughes0512f022012-03-15 22:10:52 -0700149static jint Field_getInt(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700150 return GetPrimitiveField(env, javaField, javaObj, 'I').GetI();
Elliott Hughes33203b52011-09-20 19:42:01 -0700151}
152
Elliott Hughes0512f022012-03-15 22:10:52 -0700153static jlong Field_getLong(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700154 return GetPrimitiveField(env, javaField, javaObj, 'J').GetJ();
Elliott Hughes33203b52011-09-20 19:42:01 -0700155}
156
Elliott Hughes0512f022012-03-15 22:10:52 -0700157static jshort Field_getShort(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700158 return GetPrimitiveField(env, javaField, javaObj, 'S').GetS();
Elliott Hughes33203b52011-09-20 19:42:01 -0700159}
160
Elliott Hughes0512f022012-03-15 22:10:52 -0700161static void SetFieldValue(Object* o, Field* f, const JValue& new_value, bool allow_references) {
Ian Rogers0045a292012-03-31 21:08:41 -0700162 if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(f->GetDeclaringClass(), true, true)) {
Elliott Hughes923e8b82012-03-23 11:44:07 -0700163 return;
164 }
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800165 switch (FieldHelper(f).GetTypeAsPrimitiveType()) {
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700166 case Primitive::kPrimBoolean:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700167 f->SetBoolean(o, new_value.GetZ());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700168 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700169 case Primitive::kPrimByte:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700170 f->SetByte(o, new_value.GetB());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700171 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700172 case Primitive::kPrimChar:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700173 f->SetChar(o, new_value.GetC());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700174 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700175 case Primitive::kPrimDouble:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700176 f->SetDouble(o, new_value.GetD());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700177 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700178 case Primitive::kPrimFloat:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700179 f->SetFloat(o, new_value.GetF());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700180 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700181 case Primitive::kPrimInt:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700182 f->SetInt(o, new_value.GetI());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700183 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700184 case Primitive::kPrimLong:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700185 f->SetLong(o, new_value.GetJ());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700186 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700187 case Primitive::kPrimShort:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700188 f->SetShort(o, new_value.GetS());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700189 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700190 case Primitive::kPrimNot:
Elliott Hughes33203b52011-09-20 19:42:01 -0700191 if (allow_references) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700192 f->SetObject(o, new_value.GetL());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700193 break;
Elliott Hughes33203b52011-09-20 19:42:01 -0700194 }
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700195 // Else fall through to report an error.
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700196 case Primitive::kPrimVoid:
Elliott Hughes33203b52011-09-20 19:42:01 -0700197 // Never okay.
Elliott Hughes5cb5ad22011-10-02 12:13:39 -0700198 Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700199 "Not a primitive field: %s", PrettyField(f).c_str());
200 return;
Elliott Hughes33203b52011-09-20 19:42:01 -0700201 }
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700202
203 // Special handling for final fields on SMP systems.
204 // We need a store/store barrier here (JMM requirement).
205 if (f->IsFinal()) {
206 ANDROID_MEMBAR_STORE();
207 }
Elliott Hughes33203b52011-09-20 19:42:01 -0700208}
209
Elliott Hughes0512f022012-03-15 22:10:52 -0700210static void Field_set(JNIEnv* env, jobject javaField, jobject javaObj, jobject javaValue) {
Ian Rogers365c1022012-06-22 15:05:28 -0700211 ScopedJniThreadState ts(env);
212 Field* f = ts.DecodeField(env->FromReflectedField(javaField));
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800213
214 // Unbox the value, if necessary.
Ian Rogers365c1022012-06-22 15:05:28 -0700215 Object* boxed_value = ts.Decode<Object*>(javaValue);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800216 JValue unboxed_value;
Elliott Hughesaaa5edc2012-05-16 15:54:30 -0700217 if (!UnboxPrimitiveForField(boxed_value, FieldHelper(f).GetType(), unboxed_value, f)) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800218 return;
219 }
220
221 // Check that the receiver is non-null and an instance of the field's declaring class.
222 Object* o = NULL;
Ian Rogers365c1022012-06-22 15:05:28 -0700223 if (!CheckReceiver(ts, javaObj, f, o)) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800224 return;
225 }
226
227 SetFieldValue(o, f, unboxed_value, true);
228}
229
Elliott Hughes0512f022012-03-15 22:10:52 -0700230static void SetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, char src_descriptor,
231 const JValue& new_value) {
Ian Rogers365c1022012-06-22 15:05:28 -0700232 ScopedJniThreadState ts(env);
233 Field* f = ts.DecodeField(env->FromReflectedField(javaField));
Elliott Hughesed1c1e32011-10-02 14:31:05 -0700234 Object* o = NULL;
Ian Rogers365c1022012-06-22 15:05:28 -0700235 if (!CheckReceiver(ts, javaObj, f, o)) {
Elliott Hughesed1c1e32011-10-02 14:31:05 -0700236 return;
Elliott Hughes33203b52011-09-20 19:42:01 -0700237 }
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800238 FieldHelper fh(f);
239 if (!fh.IsPrimitiveType()) {
Ian Rogers365c1022012-06-22 15:05:28 -0700240 ts.Self()->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
Jesse Wilsonc129a6b2011-11-24 14:47:46 -0500241 "Not a primitive field: %s", PrettyField(f).c_str());
242 return;
243 }
Elliott Hughes33203b52011-09-20 19:42:01 -0700244
245 // Widen the value if necessary (and possible).
246 JValue wide_value;
Elliott Hughes582a7d12011-10-10 18:38:42 -0700247 Class* src_type = Runtime::Current()->GetClassLinker()->FindPrimitiveClass(src_descriptor);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800248 if (!ConvertPrimitiveValue(src_type->GetPrimitiveType(), fh.GetTypeAsPrimitiveType(),
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700249 new_value, wide_value)) {
Elliott Hughes33203b52011-09-20 19:42:01 -0700250 return;
251 }
252
253 // Write the value.
254 SetFieldValue(o, f, wide_value, false);
255}
256
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700257static void Field_setBoolean(JNIEnv* env, jobject javaField, jobject javaObj, jboolean z) {
258 JValue value;
259 value.SetZ(z);
260 SetPrimitiveField(env, javaField, javaObj, 'Z', value);
Elliott Hughes33203b52011-09-20 19:42:01 -0700261}
262
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700263static void Field_setByte(JNIEnv* env, jobject javaField, jobject javaObj, jbyte b) {
264 JValue value;
265 value.SetB(b);
266 SetPrimitiveField(env, javaField, javaObj, 'B', value);
Elliott Hughes33203b52011-09-20 19:42:01 -0700267}
268
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700269static void Field_setChar(JNIEnv* env, jobject javaField, jobject javaObj, jchar c) {
270 JValue value;
271 value.SetC(c);
272 SetPrimitiveField(env, javaField, javaObj, 'C', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800273}
Elliott Hughes33203b52011-09-20 19:42:01 -0700274
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700275static void Field_setDouble(JNIEnv* env, jobject javaField, jobject javaObj, jdouble d) {
276 JValue value;
277 value.SetD(d);
278 SetPrimitiveField(env, javaField, javaObj, 'D', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800279}
Elliott Hughes33203b52011-09-20 19:42:01 -0700280
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700281static void Field_setFloat(JNIEnv* env, jobject javaField, jobject javaObj, jfloat f) {
282 JValue value;
283 value.SetF(f);
284 SetPrimitiveField(env, javaField, javaObj, 'F', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800285}
286
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700287static void Field_setInt(JNIEnv* env, jobject javaField, jobject javaObj, jint i) {
288 JValue value;
289 value.SetI(i);
290 SetPrimitiveField(env, javaField, javaObj, 'I', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800291}
292
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700293static void Field_setLong(JNIEnv* env, jobject javaField, jobject javaObj, jlong j) {
294 JValue value;
295 value.SetJ(j);
296 SetPrimitiveField(env, javaField, javaObj, 'J', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800297}
298
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700299static void Field_setShort(JNIEnv* env, jobject javaField, jobject javaObj, jshort s) {
300 JValue value;
301 value.SetS(s);
302 SetPrimitiveField(env, javaField, javaObj, 'S', value);
Elliott Hughes33203b52011-09-20 19:42:01 -0700303}
304
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700305static JNINativeMethod gMethods[] = {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800306 NATIVE_METHOD(Field, get, "(Ljava/lang/Object;)Ljava/lang/Object;"),
307 NATIVE_METHOD(Field, getBoolean, "(Ljava/lang/Object;)Z"),
308 NATIVE_METHOD(Field, getByte, "(Ljava/lang/Object;)B"),
309 NATIVE_METHOD(Field, getChar, "(Ljava/lang/Object;)C"),
310 NATIVE_METHOD(Field, getDouble, "(Ljava/lang/Object;)D"),
311 NATIVE_METHOD(Field, getFloat, "(Ljava/lang/Object;)F"),
312 NATIVE_METHOD(Field, getInt, "(Ljava/lang/Object;)I"),
313 NATIVE_METHOD(Field, getLong, "(Ljava/lang/Object;)J"),
314 NATIVE_METHOD(Field, getShort, "(Ljava/lang/Object;)S"),
315 NATIVE_METHOD(Field, set, "(Ljava/lang/Object;Ljava/lang/Object;)V"),
316 NATIVE_METHOD(Field, setBoolean, "(Ljava/lang/Object;Z)V"),
317 NATIVE_METHOD(Field, setByte, "(Ljava/lang/Object;B)V"),
318 NATIVE_METHOD(Field, setChar, "(Ljava/lang/Object;C)V"),
319 NATIVE_METHOD(Field, setDouble, "(Ljava/lang/Object;D)V"),
320 NATIVE_METHOD(Field, setFloat, "(Ljava/lang/Object;F)V"),
321 NATIVE_METHOD(Field, setInt, "(Ljava/lang/Object;I)V"),
322 NATIVE_METHOD(Field, setLong, "(Ljava/lang/Object;J)V"),
323 NATIVE_METHOD(Field, setShort, "(Ljava/lang/Object;S)V"),
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700324};
325
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700326void register_java_lang_reflect_Field(JNIEnv* env) {
Elliott Hugheseac76672012-05-24 21:56:51 -0700327 REGISTER_NATIVE_METHODS("java/lang/reflect/Field");
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700328}
329
330} // namespace art