blob: 7b4e8564b0364dca282b01f2836f95c2b772f317 [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;
33
34namespace annotations {
35
36// Field annotations.
37mirror::Object* GetAnnotationForField(ArtField* field, Handle<mirror::Class> annotation_class)
38 REQUIRES_SHARED(Locks::mutator_lock_);
39mirror::ObjectArray<mirror::Object>* GetAnnotationsForField(ArtField* field)
40 REQUIRES_SHARED(Locks::mutator_lock_);
41mirror::ObjectArray<mirror::String>* GetSignatureAnnotationForField(ArtField* field)
42 REQUIRES_SHARED(Locks::mutator_lock_);
43bool IsFieldAnnotationPresent(ArtField* field, Handle<mirror::Class> annotation_class)
44 REQUIRES_SHARED(Locks::mutator_lock_);
45
46// Method annotations.
47mirror::Object* GetAnnotationDefaultValue(ArtMethod* method)
48 REQUIRES_SHARED(Locks::mutator_lock_);
49mirror::Object* GetAnnotationForMethod(ArtMethod* method, Handle<mirror::Class> annotation_class)
50 REQUIRES_SHARED(Locks::mutator_lock_);
51mirror::ObjectArray<mirror::Object>* GetAnnotationsForMethod(ArtMethod* method)
52 REQUIRES_SHARED(Locks::mutator_lock_);
53mirror::ObjectArray<mirror::Class>* GetExceptionTypesForMethod(ArtMethod* method)
54 REQUIRES_SHARED(Locks::mutator_lock_);
55mirror::ObjectArray<mirror::Object>* GetParameterAnnotations(ArtMethod* method)
56 REQUIRES_SHARED(Locks::mutator_lock_);
57mirror::Object* GetAnnotationForMethodParameter(ArtMethod* method,
58 uint32_t parameter_idx,
59 Handle<mirror::Class> annotation_class)
60 REQUIRES_SHARED(Locks::mutator_lock_);
61mirror::ObjectArray<mirror::String>* GetSignatureAnnotationForMethod(ArtMethod* method)
62 REQUIRES_SHARED(Locks::mutator_lock_);
63bool IsMethodAnnotationPresent(ArtMethod* method, Handle<mirror::Class> annotation_class,
64 uint32_t visibility = DexFile::kDexVisibilityRuntime)
65 REQUIRES_SHARED(Locks::mutator_lock_);
66
67// Class annotations.
68mirror::Object* GetAnnotationForClass(Handle<mirror::Class> klass,
69 Handle<mirror::Class> annotation_class)
70 REQUIRES_SHARED(Locks::mutator_lock_);
71mirror::ObjectArray<mirror::Object>* GetAnnotationsForClass(Handle<mirror::Class> klass)
72 REQUIRES_SHARED(Locks::mutator_lock_);
73mirror::ObjectArray<mirror::Class>* GetDeclaredClasses(Handle<mirror::Class> klass)
74 REQUIRES_SHARED(Locks::mutator_lock_);
75mirror::Class* GetDeclaringClass(Handle<mirror::Class> klass)
76 REQUIRES_SHARED(Locks::mutator_lock_);
77mirror::Class* GetEnclosingClass(Handle<mirror::Class> klass)
78 REQUIRES_SHARED(Locks::mutator_lock_);
79mirror::Object* GetEnclosingMethod(Handle<mirror::Class> klass)
80 REQUIRES_SHARED(Locks::mutator_lock_);
81bool GetInnerClass(Handle<mirror::Class> klass, mirror::String** name)
82 REQUIRES_SHARED(Locks::mutator_lock_);
83bool GetInnerClassFlags(Handle<mirror::Class> klass, uint32_t* flags)
84 REQUIRES_SHARED(Locks::mutator_lock_);
85mirror::ObjectArray<mirror::String>* GetSignatureAnnotationForClass(Handle<mirror::Class> klass)
86 REQUIRES_SHARED(Locks::mutator_lock_);
87bool IsClassAnnotationPresent(Handle<mirror::Class> klass,
88 Handle<mirror::Class> annotation_class)
89 REQUIRES_SHARED(Locks::mutator_lock_);
90
91// Map back from a PC to the line number in a method.
92int32_t GetLineNumFromPC(const DexFile* dex_file, ArtMethod* method, uint32_t rel_pc)
93 REQUIRES_SHARED(Locks::mutator_lock_);
94
95// Annotations iterator.
96class RuntimeEncodedStaticFieldValueIterator : public EncodedStaticFieldValueIterator {
97 public:
98 // A constructor meant to be called from runtime code.
99 RuntimeEncodedStaticFieldValueIterator(const DexFile& dex_file,
100 Handle<mirror::DexCache>* dex_cache,
101 Handle<mirror::ClassLoader>* class_loader,
102 ClassLinker* linker,
103 const DexFile::ClassDef& class_def)
104 REQUIRES_SHARED(Locks::mutator_lock_)
105 : EncodedStaticFieldValueIterator(dex_file, class_def),
106 dex_cache_(dex_cache),
107 class_loader_(class_loader),
108 linker_(linker) {
109 }
110
111 template<bool kTransactionActive>
112 void ReadValueToField(ArtField* field) const REQUIRES_SHARED(Locks::mutator_lock_);
113
114 private:
115 Handle<mirror::DexCache>* const dex_cache_; // Dex cache to resolve literal objects.
116 Handle<mirror::ClassLoader>* const class_loader_; // ClassLoader to resolve types.
117 ClassLinker* linker_; // Linker to resolve literal objects.
118 DISALLOW_IMPLICIT_CONSTRUCTORS(RuntimeEncodedStaticFieldValueIterator);
119};
120
121} // namespace annotations
122
123} // namespace art
124
125#endif // ART_RUNTIME_DEX_FILE_ANNOTATIONS_H_