blob: c82e5034b74d850b13ba723360171b6730db1a06 [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 Rogers00f7d0e2012-07-19 15:28:27 -070022#include "scoped_thread_state_change.h"
Brian Carlstromf867b6f2011-09-16 12:17:25 -070023
Brian Carlstromf867b6f2011-09-16 12:17:25 -070024namespace art {
25
Ian Rogers00f7d0e2012-07-19 15:28:27 -070026static bool GetFieldValue(const ScopedObjectAccess& soa, Object* o, Field* f,
27 JValue& value, bool allow_references)
Ian Rogersb726dcb2012-09-05 08:57:23 -070028 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070029 DCHECK_EQ(value.GetJ(), 0LL);
Ian Rogers00f7d0e2012-07-19 15:28:27 -070030 if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(f->GetDeclaringClass(),
31 true, true)) {
Elliott Hughes923e8b82012-03-23 11:44:07 -070032 return false;
33 }
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080034 switch (FieldHelper(f).GetTypeAsPrimitiveType()) {
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070035 case Primitive::kPrimBoolean:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070036 value.SetZ(f->GetBoolean(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070037 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070038 case Primitive::kPrimByte:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070039 value.SetB(f->GetByte(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070040 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070041 case Primitive::kPrimChar:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070042 value.SetC(f->GetChar(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070043 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070044 case Primitive::kPrimDouble:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070045 value.SetD(f->GetDouble(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070046 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070047 case Primitive::kPrimFloat:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070048 value.SetF(f->GetFloat(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070049 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070050 case Primitive::kPrimInt:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070051 value.SetI(f->GetInt(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070052 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070053 case Primitive::kPrimLong:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070054 value.SetJ(f->GetLong(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070055 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070056 case Primitive::kPrimShort:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070057 value.SetS(f->GetShort(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070058 return true;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070059 case Primitive::kPrimNot:
Elliott Hughes33203b52011-09-20 19:42:01 -070060 if (allow_references) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -070061 value.SetL(f->GetObject(o));
Elliott Hughes33203b52011-09-20 19:42:01 -070062 return true;
63 }
64 // Else break to report an error.
65 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070066 case Primitive::kPrimVoid:
Elliott Hughes33203b52011-09-20 19:42:01 -070067 // Never okay.
68 break;
69 }
Ian Rogers00f7d0e2012-07-19 15:28:27 -070070 soa.Self()->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
Elliott Hughes33203b52011-09-20 19:42:01 -070071 "Not a primitive field: %s", PrettyField(f).c_str());
72 return false;
73}
74
Ian Rogers00f7d0e2012-07-19 15:28:27 -070075static bool CheckReceiver(const ScopedObjectAccess& soa, jobject javaObj, Field* f,
76 Object*& o)
Ian Rogersb726dcb2012-09-05 08:57:23 -070077 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Elliott Hughesed1c1e32011-10-02 14:31:05 -070078 if (f->IsStatic()) {
79 o = NULL;
80 return true;
81 }
82
Ian Rogers00f7d0e2012-07-19 15:28:27 -070083 o = soa.Decode<Object*>(javaObj);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080084 Class* declaringClass = f->GetDeclaringClass();
Elliott Hugheseac76672012-05-24 21:56:51 -070085 if (!VerifyObjectInClass(o, declaringClass)) {
Elliott Hughesed1c1e32011-10-02 14:31:05 -070086 return false;
87 }
88 return true;
89}
90
Elliott Hughes0512f022012-03-15 22:10:52 -070091static jobject Field_get(JNIEnv* env, jobject javaField, jobject javaObj) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -070092 ScopedObjectAccess soa(env);
93 Field* f = soa.DecodeField(env->FromReflectedField(javaField));
Elliott Hughesed1c1e32011-10-02 14:31:05 -070094 Object* o = NULL;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070095 if (!CheckReceiver(soa, javaObj, f, o)) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080096 return NULL;
97 }
98
99 // Get the field's value, boxing if necessary.
Elliott Hughes1d878f32012-04-11 15:17:54 -0700100 JValue value;
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700101 if (!GetFieldValue(soa, o, f, value, true)) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800102 return NULL;
103 }
Elliott Hughesdbac3092012-03-16 18:00:30 -0700104 BoxPrimitive(FieldHelper(f).GetTypeAsPrimitiveType(), value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800105
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700106 return soa.AddLocalReference<jobject>(value.GetL());
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800107}
108
Elliott Hughes0512f022012-03-15 22:10:52 -0700109static JValue GetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, char dst_descriptor) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700110 ScopedObjectAccess soa(env);
111 Field* f = soa.DecodeField(env->FromReflectedField(javaField));
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800112 Object* o = NULL;
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700113 if (!CheckReceiver(soa, javaObj, f, o)) {
Elliott Hughesed1c1e32011-10-02 14:31:05 -0700114 return JValue();
Elliott Hughes33203b52011-09-20 19:42:01 -0700115 }
116
117 // Read the value.
Elliott Hughes1d878f32012-04-11 15:17:54 -0700118 JValue field_value;
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700119 if (!GetFieldValue(soa, o, f, field_value, false)) {
Elliott Hughes33203b52011-09-20 19:42:01 -0700120 return JValue();
121 }
122
123 // Widen it if necessary (and possible).
124 JValue wide_value;
Elliott Hughes582a7d12011-10-10 18:38:42 -0700125 Class* dst_type = Runtime::Current()->GetClassLinker()->FindPrimitiveClass(dst_descriptor);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800126 if (!ConvertPrimitiveValue(FieldHelper(f).GetTypeAsPrimitiveType(), dst_type->GetPrimitiveType(),
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700127 field_value, wide_value)) {
Elliott Hughes33203b52011-09-20 19:42:01 -0700128 return JValue();
129 }
130 return wide_value;
131}
132
Elliott Hughes0512f022012-03-15 22:10:52 -0700133static jboolean Field_getBoolean(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700134 return GetPrimitiveField(env, javaField, javaObj, 'Z').GetZ();
Elliott Hughes33203b52011-09-20 19:42:01 -0700135}
136
Elliott Hughes0512f022012-03-15 22:10:52 -0700137static jbyte Field_getByte(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700138 return GetPrimitiveField(env, javaField, javaObj, 'B').GetB();
Elliott Hughes33203b52011-09-20 19:42:01 -0700139}
140
Elliott Hughes0512f022012-03-15 22:10:52 -0700141static jchar Field_getChar(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700142 return GetPrimitiveField(env, javaField, javaObj, 'C').GetC();
Elliott Hughes33203b52011-09-20 19:42:01 -0700143}
144
Elliott Hughes0512f022012-03-15 22:10:52 -0700145static jdouble Field_getDouble(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700146 return GetPrimitiveField(env, javaField, javaObj, 'D').GetD();
Elliott Hughes33203b52011-09-20 19:42:01 -0700147}
148
Elliott Hughes0512f022012-03-15 22:10:52 -0700149static jfloat Field_getFloat(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700150 return GetPrimitiveField(env, javaField, javaObj, 'F').GetF();
Elliott Hughes33203b52011-09-20 19:42:01 -0700151}
152
Elliott Hughes0512f022012-03-15 22:10:52 -0700153static jint Field_getInt(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700154 return GetPrimitiveField(env, javaField, javaObj, 'I').GetI();
Elliott Hughes33203b52011-09-20 19:42:01 -0700155}
156
Elliott Hughes0512f022012-03-15 22:10:52 -0700157static jlong Field_getLong(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700158 return GetPrimitiveField(env, javaField, javaObj, 'J').GetJ();
Elliott Hughes33203b52011-09-20 19:42:01 -0700159}
160
Elliott Hughes0512f022012-03-15 22:10:52 -0700161static jshort Field_getShort(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700162 return GetPrimitiveField(env, javaField, javaObj, 'S').GetS();
Elliott Hughes33203b52011-09-20 19:42:01 -0700163}
164
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700165static void SetFieldValue(Object* o, Field* f, const JValue& new_value, bool allow_references)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700166 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700167 if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(f->GetDeclaringClass(),
168 true, true)) {
Elliott Hughes923e8b82012-03-23 11:44:07 -0700169 return;
170 }
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800171 switch (FieldHelper(f).GetTypeAsPrimitiveType()) {
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700172 case Primitive::kPrimBoolean:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700173 f->SetBoolean(o, new_value.GetZ());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700174 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700175 case Primitive::kPrimByte:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700176 f->SetByte(o, new_value.GetB());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700177 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700178 case Primitive::kPrimChar:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700179 f->SetChar(o, new_value.GetC());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700180 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700181 case Primitive::kPrimDouble:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700182 f->SetDouble(o, new_value.GetD());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700183 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700184 case Primitive::kPrimFloat:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700185 f->SetFloat(o, new_value.GetF());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700186 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700187 case Primitive::kPrimInt:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700188 f->SetInt(o, new_value.GetI());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700189 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700190 case Primitive::kPrimLong:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700191 f->SetLong(o, new_value.GetJ());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700192 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700193 case Primitive::kPrimShort:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700194 f->SetShort(o, new_value.GetS());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700195 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700196 case Primitive::kPrimNot:
Elliott Hughes33203b52011-09-20 19:42:01 -0700197 if (allow_references) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700198 f->SetObject(o, new_value.GetL());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700199 break;
Elliott Hughes33203b52011-09-20 19:42:01 -0700200 }
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700201 // Else fall through to report an error.
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700202 case Primitive::kPrimVoid:
Elliott Hughes33203b52011-09-20 19:42:01 -0700203 // Never okay.
Elliott Hughes5cb5ad22011-10-02 12:13:39 -0700204 Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700205 "Not a primitive field: %s", PrettyField(f).c_str());
206 return;
Elliott Hughes33203b52011-09-20 19:42:01 -0700207 }
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700208
209 // Special handling for final fields on SMP systems.
210 // We need a store/store barrier here (JMM requirement).
211 if (f->IsFinal()) {
212 ANDROID_MEMBAR_STORE();
213 }
Elliott Hughes33203b52011-09-20 19:42:01 -0700214}
215
Elliott Hughes0512f022012-03-15 22:10:52 -0700216static void Field_set(JNIEnv* env, jobject javaField, jobject javaObj, jobject javaValue) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700217 ScopedObjectAccess soa(env);
218 Field* f = soa.DecodeField(env->FromReflectedField(javaField));
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800219
220 // Unbox the value, if necessary.
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700221 Object* boxed_value = soa.Decode<Object*>(javaValue);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800222 JValue unboxed_value;
Elliott Hughesaaa5edc2012-05-16 15:54:30 -0700223 if (!UnboxPrimitiveForField(boxed_value, FieldHelper(f).GetType(), unboxed_value, f)) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800224 return;
225 }
226
227 // Check that the receiver is non-null and an instance of the field's declaring class.
228 Object* o = NULL;
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700229 if (!CheckReceiver(soa, javaObj, f, o)) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800230 return;
231 }
232
233 SetFieldValue(o, f, unboxed_value, true);
234}
235
Elliott Hughes0512f022012-03-15 22:10:52 -0700236static void SetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, char src_descriptor,
237 const JValue& new_value) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700238 ScopedObjectAccess soa(env);
239 Field* f = soa.DecodeField(env->FromReflectedField(javaField));
Elliott Hughesed1c1e32011-10-02 14:31:05 -0700240 Object* o = NULL;
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700241 if (!CheckReceiver(soa, javaObj, f, o)) {
Elliott Hughesed1c1e32011-10-02 14:31:05 -0700242 return;
Elliott Hughes33203b52011-09-20 19:42:01 -0700243 }
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800244 FieldHelper fh(f);
245 if (!fh.IsPrimitiveType()) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700246 soa.Self()->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
Jesse Wilsonc129a6b2011-11-24 14:47:46 -0500247 "Not a primitive field: %s", PrettyField(f).c_str());
248 return;
249 }
Elliott Hughes33203b52011-09-20 19:42:01 -0700250
251 // Widen the value if necessary (and possible).
252 JValue wide_value;
Elliott Hughes582a7d12011-10-10 18:38:42 -0700253 Class* src_type = Runtime::Current()->GetClassLinker()->FindPrimitiveClass(src_descriptor);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800254 if (!ConvertPrimitiveValue(src_type->GetPrimitiveType(), fh.GetTypeAsPrimitiveType(),
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700255 new_value, wide_value)) {
Elliott Hughes33203b52011-09-20 19:42:01 -0700256 return;
257 }
258
259 // Write the value.
260 SetFieldValue(o, f, wide_value, false);
261}
262
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700263static void Field_setBoolean(JNIEnv* env, jobject javaField, jobject javaObj, jboolean z) {
264 JValue value;
265 value.SetZ(z);
266 SetPrimitiveField(env, javaField, javaObj, 'Z', value);
Elliott Hughes33203b52011-09-20 19:42:01 -0700267}
268
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700269static void Field_setByte(JNIEnv* env, jobject javaField, jobject javaObj, jbyte b) {
270 JValue value;
271 value.SetB(b);
272 SetPrimitiveField(env, javaField, javaObj, 'B', value);
Elliott Hughes33203b52011-09-20 19:42:01 -0700273}
274
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700275static void Field_setChar(JNIEnv* env, jobject javaField, jobject javaObj, jchar c) {
276 JValue value;
277 value.SetC(c);
278 SetPrimitiveField(env, javaField, javaObj, 'C', 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_setDouble(JNIEnv* env, jobject javaField, jobject javaObj, jdouble d) {
282 JValue value;
283 value.SetD(d);
284 SetPrimitiveField(env, javaField, javaObj, 'D', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800285}
Elliott Hughes33203b52011-09-20 19:42:01 -0700286
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700287static void Field_setFloat(JNIEnv* env, jobject javaField, jobject javaObj, jfloat f) {
288 JValue value;
289 value.SetF(f);
290 SetPrimitiveField(env, javaField, javaObj, 'F', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800291}
292
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700293static void Field_setInt(JNIEnv* env, jobject javaField, jobject javaObj, jint i) {
294 JValue value;
295 value.SetI(i);
296 SetPrimitiveField(env, javaField, javaObj, 'I', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800297}
298
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700299static void Field_setLong(JNIEnv* env, jobject javaField, jobject javaObj, jlong j) {
300 JValue value;
301 value.SetJ(j);
302 SetPrimitiveField(env, javaField, javaObj, 'J', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800303}
304
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700305static void Field_setShort(JNIEnv* env, jobject javaField, jobject javaObj, jshort s) {
306 JValue value;
307 value.SetS(s);
308 SetPrimitiveField(env, javaField, javaObj, 'S', value);
Elliott Hughes33203b52011-09-20 19:42:01 -0700309}
310
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700311static JNINativeMethod gMethods[] = {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800312 NATIVE_METHOD(Field, get, "(Ljava/lang/Object;)Ljava/lang/Object;"),
313 NATIVE_METHOD(Field, getBoolean, "(Ljava/lang/Object;)Z"),
314 NATIVE_METHOD(Field, getByte, "(Ljava/lang/Object;)B"),
315 NATIVE_METHOD(Field, getChar, "(Ljava/lang/Object;)C"),
316 NATIVE_METHOD(Field, getDouble, "(Ljava/lang/Object;)D"),
317 NATIVE_METHOD(Field, getFloat, "(Ljava/lang/Object;)F"),
318 NATIVE_METHOD(Field, getInt, "(Ljava/lang/Object;)I"),
319 NATIVE_METHOD(Field, getLong, "(Ljava/lang/Object;)J"),
320 NATIVE_METHOD(Field, getShort, "(Ljava/lang/Object;)S"),
321 NATIVE_METHOD(Field, set, "(Ljava/lang/Object;Ljava/lang/Object;)V"),
322 NATIVE_METHOD(Field, setBoolean, "(Ljava/lang/Object;Z)V"),
323 NATIVE_METHOD(Field, setByte, "(Ljava/lang/Object;B)V"),
324 NATIVE_METHOD(Field, setChar, "(Ljava/lang/Object;C)V"),
325 NATIVE_METHOD(Field, setDouble, "(Ljava/lang/Object;D)V"),
326 NATIVE_METHOD(Field, setFloat, "(Ljava/lang/Object;F)V"),
327 NATIVE_METHOD(Field, setInt, "(Ljava/lang/Object;I)V"),
328 NATIVE_METHOD(Field, setLong, "(Ljava/lang/Object;J)V"),
329 NATIVE_METHOD(Field, setShort, "(Ljava/lang/Object;S)V"),
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700330};
331
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700332void register_java_lang_reflect_Field(JNIEnv* env) {
Elliott Hugheseac76672012-05-24 21:56:51 -0700333 REGISTER_NATIVE_METHODS("java/lang/reflect/Field");
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700334}
335
336} // namespace art