blob: 61370c650e018b13348d9df841020d72528c7d0a [file] [log] [blame]
Elliott Hughes418d20f2011-09-22 14:00:39 -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
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_REFLECTION_H_
18#define ART_RUNTIME_REFLECTION_H_
Elliott Hughes418d20f2011-09-22 14:00:39 -070019
Ian Rogers68d8b422014-07-17 11:09:10 -070020#include "base/mutex.h"
Elliott Hughes418d20f2011-09-22 14:00:39 -070021#include "jni.h"
Brian Carlstrom6b4ef022011-10-23 14:59:04 -070022#include "primitive.h"
Elliott Hughes418d20f2011-09-22 14:00:39 -070023
24namespace art {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080025namespace mirror {
Brian Carlstromea46f952013-07-30 01:26:50 -070026 class ArtField;
27 class ArtMethod;
28 class Class;
29 class Object;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080030} // namespace mirror
31union JValue;
Ian Rogers53b8b092014-03-13 23:45:53 -070032class MethodHelper;
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -070033class ScopedObjectAccessAlreadyRunnable;
Ian Rogers53b8b092014-03-13 23:45:53 -070034class ShadowFrame;
Ian Rogers62d6c772013-02-27 08:32:07 -080035class ThrowLocation;
Elliott Hughes418d20f2011-09-22 14:00:39 -070036
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080037mirror::Object* BoxPrimitive(Primitive::Type src_class, const JValue& value)
Ian Rogersb726dcb2012-09-05 08:57:23 -070038 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers84956ff2014-03-26 23:52:41 -070039bool UnboxPrimitiveForField(mirror::Object* o, mirror::Class* dst_class, mirror::ArtField* f,
40 JValue* unboxed_value)
Ian Rogersb726dcb2012-09-05 08:57:23 -070041 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -080042bool UnboxPrimitiveForResult(const ThrowLocation& throw_location, mirror::Object* o,
Ian Rogers84956ff2014-03-26 23:52:41 -070043 mirror::Class* dst_class, JValue* unboxed_value)
Ian Rogersb726dcb2012-09-05 08:57:23 -070044 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes418d20f2011-09-22 14:00:39 -070045
Ian Rogers62d6c772013-02-27 08:32:07 -080046bool ConvertPrimitiveValue(const ThrowLocation* throw_location, bool unbox_for_result,
47 Primitive::Type src_class, Primitive::Type dst_class,
Ian Rogers84956ff2014-03-26 23:52:41 -070048 const JValue& src, JValue* dst)
Ian Rogersb726dcb2012-09-05 08:57:23 -070049 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes418d20f2011-09-22 14:00:39 -070050
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -070051JValue InvokeWithVarArgs(const ScopedObjectAccessAlreadyRunnable& soa, jobject obj, jmethodID mid,
52 va_list args)
Ian Rogersb726dcb2012-09-05 08:57:23 -070053 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes2a20cfd2011-09-23 19:30:41 -070054
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -070055JValue InvokeWithJValues(const ScopedObjectAccessAlreadyRunnable& soa, mirror::Object* receiver,
Ian Rogers53b8b092014-03-13 23:45:53 -070056 jmethodID mid, jvalue* args)
57 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
58
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -070059JValue InvokeVirtualOrInterfaceWithJValues(const ScopedObjectAccessAlreadyRunnable& soa,
Ian Rogers53b8b092014-03-13 23:45:53 -070060 mirror::Object* receiver, jmethodID mid, jvalue* args)
61 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
62
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -070063JValue InvokeVirtualOrInterfaceWithVarArgs(const ScopedObjectAccessAlreadyRunnable& soa,
Ian Rogers53b8b092014-03-13 23:45:53 -070064 jobject obj, jmethodID mid, va_list args)
65 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
66
67void InvokeWithShadowFrame(Thread* self, ShadowFrame* shadow_frame, uint16_t arg_offset,
68 MethodHelper& mh, JValue* result)
69 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
70
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -070071jobject InvokeMethod(const ScopedObjectAccessAlreadyRunnable& soa, jobject method, jobject receiver,
Jeff Hao11d5d8f2014-03-26 15:08:20 -070072 jobject args, bool accessible)
Ian Rogers53b8b092014-03-13 23:45:53 -070073 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
74
75bool VerifyObjectIsClass(mirror::Object* o, mirror::Class* c)
Ian Rogersb726dcb2012-09-05 08:57:23 -070076 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes418d20f2011-09-22 14:00:39 -070077
Jeff Haocb4581a2014-03-28 15:43:37 -070078bool VerifyAccess(mirror::Object* obj, mirror::Class* declaring_class, uint32_t access_flags)
Jeff Hao11d5d8f2014-03-26 15:08:20 -070079 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
80
Elliott Hughes418d20f2011-09-22 14:00:39 -070081} // namespace art
82
Brian Carlstromfc0e3212013-07-17 14:40:12 -070083#endif // ART_RUNTIME_REFLECTION_H_