blob: 651c9844eb5fa0023ca940cac770ee8f92233210 [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_);
Orion Hodson77d8a1c2017-04-24 14:53:19 +010092const char* GetSourceDebugExtension(Handle<mirror::Class> klass)
93 REQUIRES_SHARED(Locks::mutator_lock_);
David Sehr9323e6e2016-09-13 08:58:35 -070094bool IsClassAnnotationPresent(Handle<mirror::Class> klass,
95 Handle<mirror::Class> annotation_class)
96 REQUIRES_SHARED(Locks::mutator_lock_);
97
98// Map back from a PC to the line number in a method.
99int32_t GetLineNumFromPC(const DexFile* dex_file, ArtMethod* method, uint32_t rel_pc)
100 REQUIRES_SHARED(Locks::mutator_lock_);
101
102// Annotations iterator.
103class RuntimeEncodedStaticFieldValueIterator : public EncodedStaticFieldValueIterator {
104 public:
105 // A constructor meant to be called from runtime code.
106 RuntimeEncodedStaticFieldValueIterator(const DexFile& dex_file,
107 Handle<mirror::DexCache>* dex_cache,
108 Handle<mirror::ClassLoader>* class_loader,
109 ClassLinker* linker,
110 const DexFile::ClassDef& class_def)
111 REQUIRES_SHARED(Locks::mutator_lock_)
112 : EncodedStaticFieldValueIterator(dex_file, class_def),
113 dex_cache_(dex_cache),
114 class_loader_(class_loader),
115 linker_(linker) {
116 }
117
118 template<bool kTransactionActive>
119 void ReadValueToField(ArtField* field) const REQUIRES_SHARED(Locks::mutator_lock_);
120
121 private:
122 Handle<mirror::DexCache>* const dex_cache_; // Dex cache to resolve literal objects.
123 Handle<mirror::ClassLoader>* const class_loader_; // ClassLoader to resolve types.
124 ClassLinker* linker_; // Linker to resolve literal objects.
125 DISALLOW_IMPLICIT_CONSTRUCTORS(RuntimeEncodedStaticFieldValueIterator);
126};
127
128} // namespace annotations
129
130} // namespace art
131
132#endif // ART_RUNTIME_DEX_FILE_ANNOTATIONS_H_