blob: fde8f949218aa485706983b1061ca256c5a4584d [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()) {
Ian Rogers2fa6b2e2012-10-17 00:10:17 -070079 o = f->GetDeclaringClass();
Elliott Hughesed1c1e32011-10-02 14:31:05 -070080 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 }
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800104 return
105 soa.AddLocalReference<jobject>(BoxPrimitive(FieldHelper(f).GetTypeAsPrimitiveType(), value));
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800106}
107
Elliott Hughes0512f022012-03-15 22:10:52 -0700108static JValue GetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, char dst_descriptor) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700109 ScopedObjectAccess soa(env);
110 Field* f = soa.DecodeField(env->FromReflectedField(javaField));
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800111 Object* o = NULL;
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700112 if (!CheckReceiver(soa, javaObj, f, o)) {
Elliott Hughesed1c1e32011-10-02 14:31:05 -0700113 return JValue();
Elliott Hughes33203b52011-09-20 19:42:01 -0700114 }
115
116 // Read the value.
Elliott Hughes1d878f32012-04-11 15:17:54 -0700117 JValue field_value;
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700118 if (!GetFieldValue(soa, o, f, field_value, false)) {
Elliott Hughes33203b52011-09-20 19:42:01 -0700119 return JValue();
120 }
121
122 // Widen it if necessary (and possible).
123 JValue wide_value;
Elliott Hughes582a7d12011-10-10 18:38:42 -0700124 Class* dst_type = Runtime::Current()->GetClassLinker()->FindPrimitiveClass(dst_descriptor);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800125 if (!ConvertPrimitiveValue(FieldHelper(f).GetTypeAsPrimitiveType(), dst_type->GetPrimitiveType(),
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700126 field_value, wide_value)) {
Elliott Hughes33203b52011-09-20 19:42:01 -0700127 return JValue();
128 }
129 return wide_value;
130}
131
Elliott Hughes0512f022012-03-15 22:10:52 -0700132static jboolean Field_getBoolean(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700133 return GetPrimitiveField(env, javaField, javaObj, 'Z').GetZ();
Elliott Hughes33203b52011-09-20 19:42:01 -0700134}
135
Elliott Hughes0512f022012-03-15 22:10:52 -0700136static jbyte Field_getByte(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700137 return GetPrimitiveField(env, javaField, javaObj, 'B').GetB();
Elliott Hughes33203b52011-09-20 19:42:01 -0700138}
139
Elliott Hughes0512f022012-03-15 22:10:52 -0700140static jchar Field_getChar(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700141 return GetPrimitiveField(env, javaField, javaObj, 'C').GetC();
Elliott Hughes33203b52011-09-20 19:42:01 -0700142}
143
Elliott Hughes0512f022012-03-15 22:10:52 -0700144static jdouble Field_getDouble(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700145 return GetPrimitiveField(env, javaField, javaObj, 'D').GetD();
Elliott Hughes33203b52011-09-20 19:42:01 -0700146}
147
Elliott Hughes0512f022012-03-15 22:10:52 -0700148static jfloat Field_getFloat(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700149 return GetPrimitiveField(env, javaField, javaObj, 'F').GetF();
Elliott Hughes33203b52011-09-20 19:42:01 -0700150}
151
Elliott Hughes0512f022012-03-15 22:10:52 -0700152static jint Field_getInt(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700153 return GetPrimitiveField(env, javaField, javaObj, 'I').GetI();
Elliott Hughes33203b52011-09-20 19:42:01 -0700154}
155
Elliott Hughes0512f022012-03-15 22:10:52 -0700156static jlong Field_getLong(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700157 return GetPrimitiveField(env, javaField, javaObj, 'J').GetJ();
Elliott Hughes33203b52011-09-20 19:42:01 -0700158}
159
Elliott Hughes0512f022012-03-15 22:10:52 -0700160static jshort Field_getShort(JNIEnv* env, jobject javaField, jobject javaObj) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700161 return GetPrimitiveField(env, javaField, javaObj, 'S').GetS();
Elliott Hughes33203b52011-09-20 19:42:01 -0700162}
163
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700164static void SetFieldValue(Object* o, Field* f, const JValue& new_value, bool allow_references)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700165 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700166 if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(f->GetDeclaringClass(),
167 true, true)) {
Elliott Hughes923e8b82012-03-23 11:44:07 -0700168 return;
169 }
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800170 switch (FieldHelper(f).GetTypeAsPrimitiveType()) {
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700171 case Primitive::kPrimBoolean:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700172 f->SetBoolean(o, new_value.GetZ());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700173 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700174 case Primitive::kPrimByte:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700175 f->SetByte(o, new_value.GetB());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700176 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700177 case Primitive::kPrimChar:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700178 f->SetChar(o, new_value.GetC());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700179 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700180 case Primitive::kPrimDouble:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700181 f->SetDouble(o, new_value.GetD());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700182 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700183 case Primitive::kPrimFloat:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700184 f->SetFloat(o, new_value.GetF());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700185 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700186 case Primitive::kPrimInt:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700187 f->SetInt(o, new_value.GetI());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700188 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700189 case Primitive::kPrimLong:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700190 f->SetLong(o, new_value.GetJ());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700191 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700192 case Primitive::kPrimShort:
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700193 f->SetShort(o, new_value.GetS());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700194 break;
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700195 case Primitive::kPrimNot:
Elliott Hughes33203b52011-09-20 19:42:01 -0700196 if (allow_references) {
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700197 f->SetObject(o, new_value.GetL());
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700198 break;
Elliott Hughes33203b52011-09-20 19:42:01 -0700199 }
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700200 // Else fall through to report an error.
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700201 case Primitive::kPrimVoid:
Elliott Hughes33203b52011-09-20 19:42:01 -0700202 // Never okay.
Elliott Hughes5cb5ad22011-10-02 12:13:39 -0700203 Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700204 "Not a primitive field: %s", PrettyField(f).c_str());
205 return;
Elliott Hughes33203b52011-09-20 19:42:01 -0700206 }
Elliott Hughesfe6207f2011-09-26 17:24:06 -0700207
208 // Special handling for final fields on SMP systems.
209 // We need a store/store barrier here (JMM requirement).
210 if (f->IsFinal()) {
211 ANDROID_MEMBAR_STORE();
212 }
Elliott Hughes33203b52011-09-20 19:42:01 -0700213}
214
Elliott Hughes0512f022012-03-15 22:10:52 -0700215static void Field_set(JNIEnv* env, jobject javaField, jobject javaObj, jobject javaValue) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700216 ScopedObjectAccess soa(env);
217 Field* f = soa.DecodeField(env->FromReflectedField(javaField));
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800218
219 // Unbox the value, if necessary.
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700220 Object* boxed_value = soa.Decode<Object*>(javaValue);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800221 JValue unboxed_value;
Elliott Hughesaaa5edc2012-05-16 15:54:30 -0700222 if (!UnboxPrimitiveForField(boxed_value, FieldHelper(f).GetType(), unboxed_value, f)) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800223 return;
224 }
225
226 // Check that the receiver is non-null and an instance of the field's declaring class.
227 Object* o = NULL;
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700228 if (!CheckReceiver(soa, javaObj, f, o)) {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800229 return;
230 }
231
232 SetFieldValue(o, f, unboxed_value, true);
233}
234
Elliott Hughes0512f022012-03-15 22:10:52 -0700235static void SetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, char src_descriptor,
236 const JValue& new_value) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700237 ScopedObjectAccess soa(env);
238 Field* f = soa.DecodeField(env->FromReflectedField(javaField));
Elliott Hughesed1c1e32011-10-02 14:31:05 -0700239 Object* o = NULL;
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700240 if (!CheckReceiver(soa, javaObj, f, o)) {
Elliott Hughesed1c1e32011-10-02 14:31:05 -0700241 return;
Elliott Hughes33203b52011-09-20 19:42:01 -0700242 }
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800243 FieldHelper fh(f);
244 if (!fh.IsPrimitiveType()) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700245 soa.Self()->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
Jesse Wilsonc129a6b2011-11-24 14:47:46 -0500246 "Not a primitive field: %s", PrettyField(f).c_str());
247 return;
248 }
Elliott Hughes33203b52011-09-20 19:42:01 -0700249
250 // Widen the value if necessary (and possible).
251 JValue wide_value;
Elliott Hughes582a7d12011-10-10 18:38:42 -0700252 Class* src_type = Runtime::Current()->GetClassLinker()->FindPrimitiveClass(src_descriptor);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800253 if (!ConvertPrimitiveValue(src_type->GetPrimitiveType(), fh.GetTypeAsPrimitiveType(),
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700254 new_value, wide_value)) {
Elliott Hughes33203b52011-09-20 19:42:01 -0700255 return;
256 }
257
258 // Write the value.
259 SetFieldValue(o, f, wide_value, false);
260}
261
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700262static void Field_setBoolean(JNIEnv* env, jobject javaField, jobject javaObj, jboolean z) {
263 JValue value;
264 value.SetZ(z);
265 SetPrimitiveField(env, javaField, javaObj, 'Z', value);
Elliott Hughes33203b52011-09-20 19:42:01 -0700266}
267
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700268static void Field_setByte(JNIEnv* env, jobject javaField, jobject javaObj, jbyte b) {
269 JValue value;
270 value.SetB(b);
271 SetPrimitiveField(env, javaField, javaObj, 'B', value);
Elliott Hughes33203b52011-09-20 19:42:01 -0700272}
273
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700274static void Field_setChar(JNIEnv* env, jobject javaField, jobject javaObj, jchar c) {
275 JValue value;
276 value.SetC(c);
277 SetPrimitiveField(env, javaField, javaObj, 'C', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800278}
Elliott Hughes33203b52011-09-20 19:42:01 -0700279
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700280static void Field_setDouble(JNIEnv* env, jobject javaField, jobject javaObj, jdouble d) {
281 JValue value;
282 value.SetD(d);
283 SetPrimitiveField(env, javaField, javaObj, 'D', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800284}
Elliott Hughes33203b52011-09-20 19:42:01 -0700285
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700286static void Field_setFloat(JNIEnv* env, jobject javaField, jobject javaObj, jfloat f) {
287 JValue value;
288 value.SetF(f);
289 SetPrimitiveField(env, javaField, javaObj, 'F', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800290}
291
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700292static void Field_setInt(JNIEnv* env, jobject javaField, jobject javaObj, jint i) {
293 JValue value;
294 value.SetI(i);
295 SetPrimitiveField(env, javaField, javaObj, 'I', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800296}
297
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700298static void Field_setLong(JNIEnv* env, jobject javaField, jobject javaObj, jlong j) {
299 JValue value;
300 value.SetJ(j);
301 SetPrimitiveField(env, javaField, javaObj, 'J', value);
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800302}
303
Elliott Hughesf24d3ce2012-04-11 17:43:37 -0700304static void Field_setShort(JNIEnv* env, jobject javaField, jobject javaObj, jshort s) {
305 JValue value;
306 value.SetS(s);
307 SetPrimitiveField(env, javaField, javaObj, 'S', value);
Elliott Hughes33203b52011-09-20 19:42:01 -0700308}
309
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700310static JNINativeMethod gMethods[] = {
Ian Rogers6d4d9fc2011-11-30 16:24:48 -0800311 NATIVE_METHOD(Field, get, "(Ljava/lang/Object;)Ljava/lang/Object;"),
312 NATIVE_METHOD(Field, getBoolean, "(Ljava/lang/Object;)Z"),
313 NATIVE_METHOD(Field, getByte, "(Ljava/lang/Object;)B"),
314 NATIVE_METHOD(Field, getChar, "(Ljava/lang/Object;)C"),
315 NATIVE_METHOD(Field, getDouble, "(Ljava/lang/Object;)D"),
316 NATIVE_METHOD(Field, getFloat, "(Ljava/lang/Object;)F"),
317 NATIVE_METHOD(Field, getInt, "(Ljava/lang/Object;)I"),
318 NATIVE_METHOD(Field, getLong, "(Ljava/lang/Object;)J"),
319 NATIVE_METHOD(Field, getShort, "(Ljava/lang/Object;)S"),
320 NATIVE_METHOD(Field, set, "(Ljava/lang/Object;Ljava/lang/Object;)V"),
321 NATIVE_METHOD(Field, setBoolean, "(Ljava/lang/Object;Z)V"),
322 NATIVE_METHOD(Field, setByte, "(Ljava/lang/Object;B)V"),
323 NATIVE_METHOD(Field, setChar, "(Ljava/lang/Object;C)V"),
324 NATIVE_METHOD(Field, setDouble, "(Ljava/lang/Object;D)V"),
325 NATIVE_METHOD(Field, setFloat, "(Ljava/lang/Object;F)V"),
326 NATIVE_METHOD(Field, setInt, "(Ljava/lang/Object;I)V"),
327 NATIVE_METHOD(Field, setLong, "(Ljava/lang/Object;J)V"),
328 NATIVE_METHOD(Field, setShort, "(Ljava/lang/Object;S)V"),
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700329};
330
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700331void register_java_lang_reflect_Field(JNIEnv* env) {
Elliott Hugheseac76672012-05-24 21:56:51 -0700332 REGISTER_NATIVE_METHODS("java/lang/reflect/Field");
Brian Carlstromf867b6f2011-09-16 12:17:25 -0700333}
334
335} // namespace art