OSDN Git Service

Revert "Prune uses library classes even without profile DO NOT MERGE"
[android-x86/art.git] / runtime / reflection.h
1 /*
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 #ifndef ART_RUNTIME_REFLECTION_H_
18 #define ART_RUNTIME_REFLECTION_H_
19
20 #include "base/mutex.h"
21 #include "jni.h"
22 #include "primitive.h"
23
24 namespace art {
25 namespace mirror {
26   class Class;
27   class Object;
28 }  // namespace mirror
29 class ArtField;
30 class ArtMethod;
31 union JValue;
32 class ScopedObjectAccessAlreadyRunnable;
33 class ShadowFrame;
34
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_);
42
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_);
47
48 JValue InvokeWithVarArgs(const ScopedObjectAccessAlreadyRunnable& soa, jobject obj, jmethodID mid,
49                          va_list args)
50     SHARED_REQUIRES(Locks::mutator_lock_);
51
52 JValue InvokeWithJValues(const ScopedObjectAccessAlreadyRunnable& soa, jobject obj, jmethodID mid,
53                          jvalue* args)
54     SHARED_REQUIRES(Locks::mutator_lock_);
55
56 JValue InvokeVirtualOrInterfaceWithJValues(const ScopedObjectAccessAlreadyRunnable& soa,
57                                            jobject obj, jmethodID mid, jvalue* args)
58     SHARED_REQUIRES(Locks::mutator_lock_);
59
60 JValue InvokeVirtualOrInterfaceWithVarArgs(const ScopedObjectAccessAlreadyRunnable& soa,
61                                            jobject obj, jmethodID mid, va_list args)
62     SHARED_REQUIRES(Locks::mutator_lock_);
63
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_);
68
69 ALWAYS_INLINE bool VerifyObjectIsClass(mirror::Object* o, mirror::Class* c)
70     SHARED_REQUIRES(Locks::mutator_lock_);
71
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_);
75
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_);
80
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_);
84
85 void InvalidReceiverError(mirror::Object* o, mirror::Class* c)
86     SHARED_REQUIRES(Locks::mutator_lock_);
87
88 void UpdateReference(Thread* self, jobject obj, mirror::Object* result)
89     SHARED_REQUIRES(Locks::mutator_lock_);
90
91 }  // namespace art
92
93 #endif  // ART_RUNTIME_REFLECTION_H_