blob: c66c5bdb8b742c7a0e9ecb3156f7dd1d89c56a1a [file] [log] [blame]
David Sehr9323e6e2016-09-13 08:58:35 -07001/*
2 * Copyright (C) 2016 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_DEX_FILE_ANNOTATIONS_H_
18#define ART_RUNTIME_DEX_FILE_ANNOTATIONS_H_
19
20#include "dex_file.h"
21
22#include "mirror/object_array.h"
23
24namespace art {
25
26namespace mirror {
27 class ClassLoader;
28 class DexCache;
29} // namespace mirror
30class ArtField;
31class ArtMethod;
32class ClassLinker;
Neil Fuller79a21e72016-09-09 14:24:51 +010033template<class T> class MutableHandle;
David Sehr9323e6e2016-09-13 08:58:35 -070034
35namespace annotations {
36
37// Field annotations.
38mirror::Object* GetAnnotationForField(ArtField* field, Handle<mirror::Class> annotation_class)
39 REQUIRES_SHARED(Locks::mutator_lock_);
40mirror::ObjectArray<mirror::Object>* GetAnnotationsForField(ArtField* field)
41 REQUIRES_SHARED(Locks::mutator_lock_);
42mirror::ObjectArray<mirror::String>* GetSignatureAnnotationForField(ArtField* field)
43 REQUIRES_SHARED(Locks::mutator_lock_);
44bool IsFieldAnnotationPresent(ArtField* field, Handle<mirror::Class> annotation_class)
45 REQUIRES_SHARED(Locks::mutator_lock_);
46
47// Method annotations.
48mirror::Object* GetAnnotationDefaultValue(ArtMethod* method)
49 REQUIRES_SHARED(Locks::mutator_lock_);
50mirror::Object* GetAnnotationForMethod(ArtMethod* method, Handle<mirror::Class> annotation_class)
51 REQUIRES_SHARED(Locks::mutator_lock_);
52mirror::ObjectArray<mirror::Object>* GetAnnotationsForMethod(ArtMethod* method)
53 REQUIRES_SHARED(Locks::mutator_lock_);
54mirror::ObjectArray<mirror::Class>* GetExceptionTypesForMethod(ArtMethod* method)
55 REQUIRES_SHARED(Locks::mutator_lock_);
56mirror::ObjectArray<mirror::Object>* GetParameterAnnotations(ArtMethod* method)
57 REQUIRES_SHARED(Locks::mutator_lock_);
58mirror::Object* GetAnnotationForMethodParameter(ArtMethod* method,
59 uint32_t parameter_idx,
60 Handle<mirror::Class> annotation_class)
61 REQUIRES_SHARED(Locks::mutator_lock_);
Neil Fuller79a21e72016-09-09 14:24:51 +010062bool GetParametersMetadataForMethod(ArtMethod* method,
63 MutableHandle<mirror::ObjectArray<mirror::String>>* names,
64 MutableHandle<mirror::IntArray>* access_flags)
65 REQUIRES_SHARED(Locks::mutator_lock_);
David Sehr9323e6e2016-09-13 08:58:35 -070066mirror::ObjectArray<mirror::String>* GetSignatureAnnotationForMethod(ArtMethod* method)
67 REQUIRES_SHARED(Locks::mutator_lock_);
68bool IsMethodAnnotationPresent(ArtMethod* method, Handle<mirror::Class> annotation_class,
69 uint32_t visibility = DexFile::kDexVisibilityRuntime)
70 REQUIRES_SHARED(Locks::mutator_lock_);
71
72// Class annotations.
73mirror::Object* GetAnnotationForClass(Handle<mirror::Class> klass,
74 Handle<mirror::Class> annotation_class)
75 REQUIRES_SHARED(Locks::mutator_lock_);
76mirror::ObjectArray<mirror::Object>* GetAnnotationsForClass(Handle<mirror::Class> klass)
77 REQUIRES_SHARED(Locks::mutator_lock_);
78mirror::ObjectArray<mirror::Class>* GetDeclaredClasses(Handle<mirror::Class> klass)
79 REQUIRES_SHARED(Locks::mutator_lock_);
80mirror::Class* GetDeclaringClass(Handle<mirror::Class> klass)
81 REQUIRES_SHARED(Locks::mutator_lock_);
82mirror::Class* GetEnclosingClass(Handle<mirror::Class> klass)
83 REQUIRES_SHARED(Locks::mutator_lock_);
84mirror::Object* GetEnclosingMethod(Handle<mirror::Class> klass)
85 REQUIRES_SHARED(Locks::mutator_lock_);
86bool GetInnerClass(Handle<mirror::Class> klass, mirror::String** name)
87 REQUIRES_SHARED(Locks::mutator_lock_);
88bool GetInnerClassFlags(Handle<mirror::Class> klass, uint32_t* flags)
89 REQUIRES_SHARED(Locks::mutator_lock_);
90mirror::ObjectArray<mirror::String>* GetSignatureAnnotationForClass(Handle<mirror::Class> klass)
91 REQUIRES_SHARED(Locks::mutator_lock_);
92bool IsClassAnnotationPresent(Handle<mirror::Class> klass,
93 Handle<mirror::Class> annotation_class)
94 REQUIRES_SHARED(Locks::mutator_lock_);
95
96// Map back from a PC to the line number in a method.
97int32_t GetLineNumFromPC(const DexFile* dex_file, ArtMethod* method, uint32_t rel_pc)
98 REQUIRES_SHARED(Locks::mutator_lock_);
99
100// Annotations iterator.
101class RuntimeEncodedStaticFieldValueIterator : public EncodedStaticFieldValueIterator {
102 public:
103 // A constructor meant to be called from runtime code.
104 RuntimeEncodedStaticFieldValueIterator(const DexFile& dex_file,
105 Handle<mirror::DexCache>* dex_cache,
106 Handle<mirror::ClassLoader>* class_loader,
107 ClassLinker* linker,
108 const DexFile::ClassDef& class_def)
109 REQUIRES_SHARED(Locks::mutator_lock_)
110 : EncodedStaticFieldValueIterator(dex_file, class_def),
111 dex_cache_(dex_cache),
112 class_loader_(class_loader),
113 linker_(linker) {
114 }
115
116 template<bool kTransactionActive>
117 void ReadValueToField(ArtField* field) const REQUIRES_SHARED(Locks::mutator_lock_);
118
119 private:
120 Handle<mirror::DexCache>* const dex_cache_; // Dex cache to resolve literal objects.
121 Handle<mirror::ClassLoader>* const class_loader_; // ClassLoader to resolve types.
122 ClassLinker* linker_; // Linker to resolve literal objects.
123 DISALLOW_IMPLICIT_CONSTRUCTORS(RuntimeEncodedStaticFieldValueIterator);
124};
125
126} // namespace annotations
127
128} // namespace art
129
130#endif // ART_RUNTIME_DEX_FILE_ANNOTATIONS_H_