blob: 7aefdaab5ae10a4cb8793051e4231a37499a7381 [file] [log] [blame]
Ian Rogers53b8b092014-03-13 23:45:53 -07001/*
2 * Copyright (C) 2011 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 "reflection.h"
18
Brian Carlstrom8edba0b2014-03-14 16:11:43 -070019#include <float.h>
Ian Rogers88e46a32014-03-14 14:37:59 -070020#include <limits.h>
Ian Rogerse63db272014-07-15 15:36:11 -070021#include "ScopedLocalRef.h"
Ian Rogers53b8b092014-03-13 23:45:53 -070022
23#include "common_compiler_test.h"
24#include "mirror/art_method-inl.h"
Ian Rogerse63db272014-07-15 15:36:11 -070025#include "scoped_thread_state_change.h"
Ian Rogers53b8b092014-03-13 23:45:53 -070026
27namespace art {
28
29// TODO: Convert to CommonRuntimeTest. Currently MakeExecutable is used.
30class ReflectionTest : public CommonCompilerTest {
31 protected:
32 virtual void SetUp() {
33 CommonCompilerTest::SetUp();
34
35 vm_ = Runtime::Current()->GetJavaVM();
36
37 // Turn on -verbose:jni for the JNI tests.
38 // gLogVerbosity.jni = true;
39
40 vm_->AttachCurrentThread(&env_, NULL);
41
42 ScopedLocalRef<jclass> aioobe(env_,
43 env_->FindClass("java/lang/ArrayIndexOutOfBoundsException"));
44 CHECK(aioobe.get() != NULL);
45 aioobe_ = reinterpret_cast<jclass>(env_->NewGlobalRef(aioobe.get()));
46
47 ScopedLocalRef<jclass> ase(env_, env_->FindClass("java/lang/ArrayStoreException"));
48 CHECK(ase.get() != NULL);
49 ase_ = reinterpret_cast<jclass>(env_->NewGlobalRef(ase.get()));
50
51 ScopedLocalRef<jclass> sioobe(env_,
52 env_->FindClass("java/lang/StringIndexOutOfBoundsException"));
53 CHECK(sioobe.get() != NULL);
54 sioobe_ = reinterpret_cast<jclass>(env_->NewGlobalRef(sioobe.get()));
55 }
56
57 void CleanUpJniEnv() {
58 if (aioobe_ != NULL) {
59 env_->DeleteGlobalRef(aioobe_);
60 aioobe_ = NULL;
61 }
62 if (ase_ != NULL) {
63 env_->DeleteGlobalRef(ase_);
64 ase_ = NULL;
65 }
66 if (sioobe_ != NULL) {
67 env_->DeleteGlobalRef(sioobe_);
68 sioobe_ = NULL;
69 }
70 }
71
72 virtual void TearDown() {
73 CleanUpJniEnv();
74 CommonCompilerTest::TearDown();
75 }
76
77 jclass GetPrimitiveClass(char descriptor) {
78 ScopedObjectAccess soa(env_);
79 mirror::Class* c = class_linker_->FindPrimitiveClass(descriptor);
80 CHECK(c != nullptr);
81 return soa.AddLocalReference<jclass>(c);
82 }
83
84 void ReflectionTestMakeExecutable(mirror::ArtMethod** method,
85 mirror::Object** receiver,
86 bool is_static, const char* method_name,
87 const char* method_signature)
88 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
89 const char* class_name = is_static ? "StaticLeafMethods" : "NonStaticLeafMethods";
90 jobject jclass_loader(LoadDex(class_name));
91 Thread* self = Thread::Current();
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070092 StackHandleScope<2> hs(self);
93 Handle<mirror::ClassLoader> class_loader(
94 hs.NewHandle(
95 ScopedObjectAccessUnchecked(self).Decode<mirror::ClassLoader*>(jclass_loader)));
Ian Rogers53b8b092014-03-13 23:45:53 -070096 if (is_static) {
97 MakeExecutable(ScopedObjectAccessUnchecked(self).Decode<mirror::ClassLoader*>(jclass_loader),
98 class_name);
99 } else {
100 MakeExecutable(nullptr, "java.lang.Class");
101 MakeExecutable(nullptr, "java.lang.Object");
102 MakeExecutable(ScopedObjectAccessUnchecked(self).Decode<mirror::ClassLoader*>(jclass_loader),
103 class_name);
104 }
105
106 mirror::Class* c = class_linker_->FindClass(self, DotToDescriptor(class_name).c_str(),
107 class_loader);
108 CHECK(c != NULL);
109
110 *method = is_static ? c->FindDirectMethod(method_name, method_signature)
111 : c->FindVirtualMethod(method_name, method_signature);
112 CHECK(method != nullptr);
113
Sebastien Hertz4e99b3d2014-06-24 14:35:40 +0200114 if (is_static) {
115 *receiver = nullptr;
116 } else {
117 // Ensure class is initialized before allocating object
Andreas Gampe277ccbd2014-11-03 21:36:10 -0800118 StackHandleScope<1> hs2(self);
119 Handle<mirror::Class> h_class(hs2.NewHandle(c));
Ian Rogers7b078e82014-09-10 14:44:24 -0700120 bool initialized = class_linker_->EnsureInitialized(self, h_class, true, true);
Sebastien Hertz4e99b3d2014-06-24 14:35:40 +0200121 CHECK(initialized);
122 *receiver = c->AllocObject(self);
123 }
Ian Rogers53b8b092014-03-13 23:45:53 -0700124
125 // Start runtime.
126 bool started = runtime_->Start();
127 CHECK(started);
128 self->TransitionFromSuspendedToRunnable();
129 }
130
131 void InvokeNopMethod(bool is_static) {
132 ScopedObjectAccess soa(env_);
133 mirror::ArtMethod* method;
134 mirror::Object* receiver;
135 ReflectionTestMakeExecutable(&method, &receiver, is_static, "nop", "()V");
136 InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), nullptr);
137 }
138
139 void InvokeIdentityByteMethod(bool is_static) {
140 ScopedObjectAccess soa(env_);
141 mirror::ArtMethod* method;
142 mirror::Object* receiver;
143 ReflectionTestMakeExecutable(&method, &receiver, is_static, "identity", "(B)B");
144 jvalue args[1];
145
146 args[0].b = 0;
147 JValue result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
148 EXPECT_EQ(0, result.GetB());
149
150 args[0].b = -1;
151 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
152 EXPECT_EQ(-1, result.GetB());
153
154 args[0].b = SCHAR_MAX;
155 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
156 EXPECT_EQ(SCHAR_MAX, result.GetB());
157
158 args[0].b = (SCHAR_MIN << 24) >> 24;
159 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
160 EXPECT_EQ(SCHAR_MIN, result.GetB());
161 }
162
163 void InvokeIdentityIntMethod(bool is_static) {
164 ScopedObjectAccess soa(env_);
165 mirror::ArtMethod* method;
166 mirror::Object* receiver;
167 ReflectionTestMakeExecutable(&method, &receiver, is_static, "identity", "(I)I");
168 jvalue args[1];
169
170 args[0].i = 0;
171 JValue result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
172 EXPECT_EQ(0, result.GetI());
173
174 args[0].i = -1;
175 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
176 EXPECT_EQ(-1, result.GetI());
177
178 args[0].i = INT_MAX;
179 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
180 EXPECT_EQ(INT_MAX, result.GetI());
181
182 args[0].i = INT_MIN;
183 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
184 EXPECT_EQ(INT_MIN, result.GetI());
185 }
186
187 void InvokeIdentityDoubleMethod(bool is_static) {
188 ScopedObjectAccess soa(env_);
189 mirror::ArtMethod* method;
190 mirror::Object* receiver;
191 ReflectionTestMakeExecutable(&method, &receiver, is_static, "identity", "(D)D");
192 jvalue args[1];
193
194 args[0].d = 0.0;
195 JValue result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700196 EXPECT_DOUBLE_EQ(0.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700197
198 args[0].d = -1.0;
199 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700200 EXPECT_DOUBLE_EQ(-1.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700201
202 args[0].d = DBL_MAX;
203 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700204 EXPECT_DOUBLE_EQ(DBL_MAX, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700205
206 args[0].d = DBL_MIN;
207 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700208 EXPECT_DOUBLE_EQ(DBL_MIN, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700209 }
210
211 void InvokeSumIntIntMethod(bool is_static) {
212 ScopedObjectAccess soa(env_);
213 mirror::ArtMethod* method;
214 mirror::Object* receiver;
215 ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(II)I");
216 jvalue args[2];
217
218 args[0].i = 1;
219 args[1].i = 2;
220 JValue result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
221 EXPECT_EQ(3, result.GetI());
222
223 args[0].i = -2;
224 args[1].i = 5;
225 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
226 EXPECT_EQ(3, result.GetI());
227
228 args[0].i = INT_MAX;
229 args[1].i = INT_MIN;
230 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
231 EXPECT_EQ(-1, result.GetI());
232
233 args[0].i = INT_MAX;
234 args[1].i = INT_MAX;
235 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
236 EXPECT_EQ(-2, result.GetI());
237 }
238
239 void InvokeSumIntIntIntMethod(bool is_static) {
240 ScopedObjectAccess soa(env_);
241 mirror::ArtMethod* method;
242 mirror::Object* receiver;
243 ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(III)I");
244 jvalue args[3];
245
246 args[0].i = 0;
247 args[1].i = 0;
248 args[2].i = 0;
249 JValue result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
250 EXPECT_EQ(0, result.GetI());
251
252 args[0].i = 1;
253 args[1].i = 2;
254 args[2].i = 3;
255 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
256 EXPECT_EQ(6, result.GetI());
257
258 args[0].i = -1;
259 args[1].i = 2;
260 args[2].i = -3;
261 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
262 EXPECT_EQ(-2, result.GetI());
263
264 args[0].i = INT_MAX;
265 args[1].i = INT_MIN;
266 args[2].i = INT_MAX;
267 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
268 EXPECT_EQ(2147483646, result.GetI());
269
270 args[0].i = INT_MAX;
271 args[1].i = INT_MAX;
272 args[2].i = INT_MAX;
273 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
274 EXPECT_EQ(2147483645, result.GetI());
275 }
276
277 void InvokeSumIntIntIntIntMethod(bool is_static) {
278 ScopedObjectAccess soa(env_);
279 mirror::ArtMethod* method;
280 mirror::Object* receiver;
281 ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(IIII)I");
282 jvalue args[4];
283
284 args[0].i = 0;
285 args[1].i = 0;
286 args[2].i = 0;
287 args[3].i = 0;
288 JValue result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
289 EXPECT_EQ(0, result.GetI());
290
291 args[0].i = 1;
292 args[1].i = 2;
293 args[2].i = 3;
294 args[3].i = 4;
295 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
296 EXPECT_EQ(10, result.GetI());
297
298 args[0].i = -1;
299 args[1].i = 2;
300 args[2].i = -3;
301 args[3].i = 4;
302 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
303 EXPECT_EQ(2, result.GetI());
304
305 args[0].i = INT_MAX;
306 args[1].i = INT_MIN;
307 args[2].i = INT_MAX;
308 args[3].i = INT_MIN;
309 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
310 EXPECT_EQ(-2, result.GetI());
311
312 args[0].i = INT_MAX;
313 args[1].i = INT_MAX;
314 args[2].i = INT_MAX;
315 args[3].i = INT_MAX;
316 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
317 EXPECT_EQ(-4, result.GetI());
318 }
319
320 void InvokeSumIntIntIntIntIntMethod(bool is_static) {
321 ScopedObjectAccess soa(env_);
322 mirror::ArtMethod* method;
323 mirror::Object* receiver;
324 ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(IIIII)I");
325 jvalue args[5];
326
327 args[0].i = 0;
328 args[1].i = 0;
329 args[2].i = 0;
330 args[3].i = 0;
331 args[4].i = 0;
332 JValue result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
333 EXPECT_EQ(0, result.GetI());
334
335 args[0].i = 1;
336 args[1].i = 2;
337 args[2].i = 3;
338 args[3].i = 4;
339 args[4].i = 5;
340 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
341 EXPECT_EQ(15, result.GetI());
342
343 args[0].i = -1;
344 args[1].i = 2;
345 args[2].i = -3;
346 args[3].i = 4;
347 args[4].i = -5;
348 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
349 EXPECT_EQ(-3, result.GetI());
350
351 args[0].i = INT_MAX;
352 args[1].i = INT_MIN;
353 args[2].i = INT_MAX;
354 args[3].i = INT_MIN;
355 args[4].i = INT_MAX;
356 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
357 EXPECT_EQ(2147483645, result.GetI());
358
359 args[0].i = INT_MAX;
360 args[1].i = INT_MAX;
361 args[2].i = INT_MAX;
362 args[3].i = INT_MAX;
363 args[4].i = INT_MAX;
364 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
365 EXPECT_EQ(2147483643, result.GetI());
366 }
367
368 void InvokeSumDoubleDoubleMethod(bool is_static) {
369 ScopedObjectAccess soa(env_);
370 mirror::ArtMethod* method;
371 mirror::Object* receiver;
372 ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(DD)D");
373 jvalue args[2];
374
375 args[0].d = 0.0;
376 args[1].d = 0.0;
377 JValue result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700378 EXPECT_DOUBLE_EQ(0.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700379
380 args[0].d = 1.0;
381 args[1].d = 2.0;
382 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700383 EXPECT_DOUBLE_EQ(3.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700384
385 args[0].d = 1.0;
386 args[1].d = -2.0;
387 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700388 EXPECT_DOUBLE_EQ(-1.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700389
390 args[0].d = DBL_MAX;
391 args[1].d = DBL_MIN;
392 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700393 EXPECT_DOUBLE_EQ(1.7976931348623157e308, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700394
395 args[0].d = DBL_MAX;
396 args[1].d = DBL_MAX;
397 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700398 EXPECT_DOUBLE_EQ(INFINITY, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700399 }
400
401 void InvokeSumDoubleDoubleDoubleMethod(bool is_static) {
402 ScopedObjectAccess soa(env_);
403 mirror::ArtMethod* method;
404 mirror::Object* receiver;
405 ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(DDD)D");
406 jvalue args[3];
407
408 args[0].d = 0.0;
409 args[1].d = 0.0;
410 args[2].d = 0.0;
411 JValue result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700412 EXPECT_DOUBLE_EQ(0.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700413
414 args[0].d = 1.0;
415 args[1].d = 2.0;
416 args[2].d = 3.0;
417 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700418 EXPECT_DOUBLE_EQ(6.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700419
420 args[0].d = 1.0;
421 args[1].d = -2.0;
422 args[2].d = 3.0;
423 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700424 EXPECT_DOUBLE_EQ(2.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700425 }
426
427 void InvokeSumDoubleDoubleDoubleDoubleMethod(bool is_static) {
428 ScopedObjectAccess soa(env_);
429 mirror::ArtMethod* method;
430 mirror::Object* receiver;
431 ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(DDDD)D");
432 jvalue args[4];
433
434 args[0].d = 0.0;
435 args[1].d = 0.0;
436 args[2].d = 0.0;
437 args[3].d = 0.0;
438 JValue result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700439 EXPECT_DOUBLE_EQ(0.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700440
441 args[0].d = 1.0;
442 args[1].d = 2.0;
443 args[2].d = 3.0;
444 args[3].d = 4.0;
445 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700446 EXPECT_DOUBLE_EQ(10.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700447
448 args[0].d = 1.0;
449 args[1].d = -2.0;
450 args[2].d = 3.0;
451 args[3].d = -4.0;
452 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700453 EXPECT_DOUBLE_EQ(-2.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700454 }
455
456 void InvokeSumDoubleDoubleDoubleDoubleDoubleMethod(bool is_static) {
457 ScopedObjectAccess soa(env_);
458 mirror::ArtMethod* method;
459 mirror::Object* receiver;
460 ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(DDDDD)D");
461 jvalue args[5];
462
463 args[0].d = 0.0;
464 args[1].d = 0.0;
465 args[2].d = 0.0;
466 args[3].d = 0.0;
467 args[4].d = 0.0;
468 JValue result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700469 EXPECT_DOUBLE_EQ(0.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700470
471 args[0].d = 1.0;
472 args[1].d = 2.0;
473 args[2].d = 3.0;
474 args[3].d = 4.0;
475 args[4].d = 5.0;
476 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700477 EXPECT_DOUBLE_EQ(15.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700478
479 args[0].d = 1.0;
480 args[1].d = -2.0;
481 args[2].d = 3.0;
482 args[3].d = -4.0;
483 args[4].d = 5.0;
484 result = InvokeWithJValues(soa, receiver, soa.EncodeMethod(method), args);
Ian Rogers647b1a82014-10-10 11:02:11 -0700485 EXPECT_DOUBLE_EQ(3.0, result.GetD());
Ian Rogers53b8b092014-03-13 23:45:53 -0700486 }
487
488 JavaVMExt* vm_;
489 JNIEnv* env_;
490 jclass aioobe_;
491 jclass ase_;
492 jclass sioobe_;
493};
494
495TEST_F(ReflectionTest, StaticMainMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700496 ScopedObjectAccess soa(Thread::Current());
497 jobject jclass_loader = LoadDex("Main");
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700498 StackHandleScope<1> hs(soa.Self());
499 Handle<mirror::ClassLoader> class_loader(
500 hs.NewHandle(soa.Decode<mirror::ClassLoader*>(jclass_loader)));
Ian Rogers53b8b092014-03-13 23:45:53 -0700501 CompileDirectMethod(class_loader, "Main", "main", "([Ljava/lang/String;)V");
502
503 mirror::Class* klass = class_linker_->FindClass(soa.Self(), "LMain;", class_loader);
504 ASSERT_TRUE(klass != NULL);
505
506 mirror::ArtMethod* method = klass->FindDirectMethod("main", "([Ljava/lang/String;)V");
507 ASSERT_TRUE(method != NULL);
508
509 // Start runtime.
510 bool started = runtime_->Start();
511 CHECK(started);
512 soa.Self()->TransitionFromSuspendedToRunnable();
513
514 jvalue args[1];
515 args[0].l = nullptr;
516 InvokeWithJValues(soa, nullptr, soa.EncodeMethod(method), args);
517}
518
519TEST_F(ReflectionTest, StaticNopMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700520 InvokeNopMethod(true);
521}
522
523TEST_F(ReflectionTest, NonStaticNopMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700524 InvokeNopMethod(false);
525}
526
527TEST_F(ReflectionTest, StaticIdentityByteMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700528 InvokeIdentityByteMethod(true);
529}
530
531TEST_F(ReflectionTest, NonStaticIdentityByteMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700532 InvokeIdentityByteMethod(false);
533}
534
535TEST_F(ReflectionTest, StaticIdentityIntMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700536 InvokeIdentityIntMethod(true);
537}
538
539TEST_F(ReflectionTest, NonStaticIdentityIntMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700540 InvokeIdentityIntMethod(false);
541}
542
543TEST_F(ReflectionTest, StaticIdentityDoubleMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700544 InvokeIdentityDoubleMethod(true);
545}
546
547TEST_F(ReflectionTest, NonStaticIdentityDoubleMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700548 InvokeIdentityDoubleMethod(false);
549}
550
551TEST_F(ReflectionTest, StaticSumIntIntMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700552 InvokeSumIntIntMethod(true);
553}
554
555TEST_F(ReflectionTest, NonStaticSumIntIntMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700556 InvokeSumIntIntMethod(false);
557}
558
559TEST_F(ReflectionTest, StaticSumIntIntIntMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700560 InvokeSumIntIntIntMethod(true);
561}
562
563TEST_F(ReflectionTest, NonStaticSumIntIntIntMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700564 InvokeSumIntIntIntMethod(false);
565}
566
567TEST_F(ReflectionTest, StaticSumIntIntIntIntMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700568 InvokeSumIntIntIntIntMethod(true);
569}
570
571TEST_F(ReflectionTest, NonStaticSumIntIntIntIntMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700572 InvokeSumIntIntIntIntMethod(false);
573}
574
575TEST_F(ReflectionTest, StaticSumIntIntIntIntIntMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700576 InvokeSumIntIntIntIntIntMethod(true);
577}
578
579TEST_F(ReflectionTest, NonStaticSumIntIntIntIntIntMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700580 InvokeSumIntIntIntIntIntMethod(false);
581}
582
583TEST_F(ReflectionTest, StaticSumDoubleDoubleMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700584 InvokeSumDoubleDoubleMethod(true);
585}
586
587TEST_F(ReflectionTest, NonStaticSumDoubleDoubleMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700588 InvokeSumDoubleDoubleMethod(false);
589}
590
591TEST_F(ReflectionTest, StaticSumDoubleDoubleDoubleMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700592 InvokeSumDoubleDoubleDoubleMethod(true);
593}
594
595TEST_F(ReflectionTest, NonStaticSumDoubleDoubleDoubleMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700596 InvokeSumDoubleDoubleDoubleMethod(false);
597}
598
599TEST_F(ReflectionTest, StaticSumDoubleDoubleDoubleDoubleMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700600 InvokeSumDoubleDoubleDoubleDoubleMethod(true);
601}
602
603TEST_F(ReflectionTest, NonStaticSumDoubleDoubleDoubleDoubleMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700604 InvokeSumDoubleDoubleDoubleDoubleMethod(false);
605}
606
607TEST_F(ReflectionTest, StaticSumDoubleDoubleDoubleDoubleDoubleMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700608 InvokeSumDoubleDoubleDoubleDoubleDoubleMethod(true);
609}
610
611TEST_F(ReflectionTest, NonStaticSumDoubleDoubleDoubleDoubleDoubleMethod) {
Ian Rogers53b8b092014-03-13 23:45:53 -0700612 InvokeSumDoubleDoubleDoubleDoubleDoubleMethod(false);
613}
614
615} // namespace art