2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ART_RUNTIME_REFLECTION_H_
18 #define ART_RUNTIME_REFLECTION_H_
20 #include "base/mutex.h"
22 #include "primitive.h"
32 class ScopedObjectAccessAlreadyRunnable;
35 mirror::Object* BoxPrimitive(Primitive::Type src_class, const JValue& value)
36 SHARED_REQUIRES(Locks::mutator_lock_);
37 bool UnboxPrimitiveForField(mirror::Object* o, mirror::Class* dst_class, ArtField* f,
38 JValue* unboxed_value)
39 SHARED_REQUIRES(Locks::mutator_lock_);
40 bool UnboxPrimitiveForResult(mirror::Object* o, mirror::Class* dst_class, JValue* unboxed_value)
41 SHARED_REQUIRES(Locks::mutator_lock_);
43 ALWAYS_INLINE bool ConvertPrimitiveValue(bool unbox_for_result,
44 Primitive::Type src_class, Primitive::Type dst_class,
45 const JValue& src, JValue* dst)
46 SHARED_REQUIRES(Locks::mutator_lock_);
48 JValue InvokeWithVarArgs(const ScopedObjectAccessAlreadyRunnable& soa, jobject obj, jmethodID mid,
50 SHARED_REQUIRES(Locks::mutator_lock_);
52 JValue InvokeWithJValues(const ScopedObjectAccessAlreadyRunnable& soa, jobject obj, jmethodID mid,
54 SHARED_REQUIRES(Locks::mutator_lock_);
56 JValue InvokeVirtualOrInterfaceWithJValues(const ScopedObjectAccessAlreadyRunnable& soa,
57 jobject obj, jmethodID mid, jvalue* args)
58 SHARED_REQUIRES(Locks::mutator_lock_);
60 JValue InvokeVirtualOrInterfaceWithVarArgs(const ScopedObjectAccessAlreadyRunnable& soa,
61 jobject obj, jmethodID mid, va_list args)
62 SHARED_REQUIRES(Locks::mutator_lock_);
64 // num_frames is number of frames we look up for access check.
65 jobject InvokeMethod(const ScopedObjectAccessAlreadyRunnable& soa, jobject method, jobject receiver,
66 jobject args, size_t num_frames = 1)
67 SHARED_REQUIRES(Locks::mutator_lock_);
69 ALWAYS_INLINE bool VerifyObjectIsClass(mirror::Object* o, mirror::Class* c)
70 SHARED_REQUIRES(Locks::mutator_lock_);
72 bool VerifyAccess(Thread* self, mirror::Object* obj, mirror::Class* declaring_class,
73 uint32_t access_flags, mirror::Class** calling_class, size_t num_frames)
74 SHARED_REQUIRES(Locks::mutator_lock_);
76 // This version takes a known calling class.
77 bool VerifyAccess(Thread* self, mirror::Object* obj, mirror::Class* declaring_class,
78 uint32_t access_flags, mirror::Class* calling_class)
79 SHARED_REQUIRES(Locks::mutator_lock_);
81 // Get the calling class by using a stack visitor, may return null for unattached native threads.
82 mirror::Class* GetCallingClass(Thread* self, size_t num_frames)
83 SHARED_REQUIRES(Locks::mutator_lock_);
85 void InvalidReceiverError(mirror::Object* o, mirror::Class* c)
86 SHARED_REQUIRES(Locks::mutator_lock_);
88 void UpdateReference(Thread* self, jobject obj, mirror::Object* result)
89 SHARED_REQUIRES(Locks::mutator_lock_);
93 #endif // ART_RUNTIME_REFLECTION_H_