David Sehr | 9323e6e | 2016-09-13 08:58:35 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 24 | namespace art { |
| 25 | |
| 26 | namespace mirror { |
| 27 | class ClassLoader; |
| 28 | class DexCache; |
| 29 | } // namespace mirror |
| 30 | class ArtField; |
| 31 | class ArtMethod; |
| 32 | class ClassLinker; |
Neil Fuller | 79a21e7 | 2016-09-09 14:24:51 +0100 | [diff] [blame] | 33 | template<class T> class MutableHandle; |
David Sehr | 9323e6e | 2016-09-13 08:58:35 -0700 | [diff] [blame] | 34 | |
| 35 | namespace annotations { |
| 36 | |
| 37 | // Field annotations. |
| 38 | mirror::Object* GetAnnotationForField(ArtField* field, Handle<mirror::Class> annotation_class) |
| 39 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 40 | mirror::ObjectArray<mirror::Object>* GetAnnotationsForField(ArtField* field) |
| 41 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 42 | mirror::ObjectArray<mirror::String>* GetSignatureAnnotationForField(ArtField* field) |
| 43 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 44 | bool IsFieldAnnotationPresent(ArtField* field, Handle<mirror::Class> annotation_class) |
| 45 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 46 | |
| 47 | // Method annotations. |
| 48 | mirror::Object* GetAnnotationDefaultValue(ArtMethod* method) |
| 49 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 50 | mirror::Object* GetAnnotationForMethod(ArtMethod* method, Handle<mirror::Class> annotation_class) |
| 51 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 52 | mirror::ObjectArray<mirror::Object>* GetAnnotationsForMethod(ArtMethod* method) |
| 53 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 54 | mirror::ObjectArray<mirror::Class>* GetExceptionTypesForMethod(ArtMethod* method) |
| 55 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 56 | mirror::ObjectArray<mirror::Object>* GetParameterAnnotations(ArtMethod* method) |
| 57 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 58 | mirror::Object* GetAnnotationForMethodParameter(ArtMethod* method, |
| 59 | uint32_t parameter_idx, |
| 60 | Handle<mirror::Class> annotation_class) |
| 61 | REQUIRES_SHARED(Locks::mutator_lock_); |
Neil Fuller | 79a21e7 | 2016-09-09 14:24:51 +0100 | [diff] [blame] | 62 | bool GetParametersMetadataForMethod(ArtMethod* method, |
| 63 | MutableHandle<mirror::ObjectArray<mirror::String>>* names, |
| 64 | MutableHandle<mirror::IntArray>* access_flags) |
| 65 | REQUIRES_SHARED(Locks::mutator_lock_); |
David Sehr | 9323e6e | 2016-09-13 08:58:35 -0700 | [diff] [blame] | 66 | mirror::ObjectArray<mirror::String>* GetSignatureAnnotationForMethod(ArtMethod* method) |
| 67 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 68 | bool IsMethodAnnotationPresent(ArtMethod* method, Handle<mirror::Class> annotation_class, |
| 69 | uint32_t visibility = DexFile::kDexVisibilityRuntime) |
| 70 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 71 | |
| 72 | // Class annotations. |
| 73 | mirror::Object* GetAnnotationForClass(Handle<mirror::Class> klass, |
| 74 | Handle<mirror::Class> annotation_class) |
| 75 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 76 | mirror::ObjectArray<mirror::Object>* GetAnnotationsForClass(Handle<mirror::Class> klass) |
| 77 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 78 | mirror::ObjectArray<mirror::Class>* GetDeclaredClasses(Handle<mirror::Class> klass) |
| 79 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 80 | mirror::Class* GetDeclaringClass(Handle<mirror::Class> klass) |
| 81 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 82 | mirror::Class* GetEnclosingClass(Handle<mirror::Class> klass) |
| 83 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 84 | mirror::Object* GetEnclosingMethod(Handle<mirror::Class> klass) |
| 85 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 86 | bool GetInnerClass(Handle<mirror::Class> klass, mirror::String** name) |
| 87 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 88 | bool GetInnerClassFlags(Handle<mirror::Class> klass, uint32_t* flags) |
| 89 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 90 | mirror::ObjectArray<mirror::String>* GetSignatureAnnotationForClass(Handle<mirror::Class> klass) |
| 91 | REQUIRES_SHARED(Locks::mutator_lock_); |
David Sehr | 9323e6e | 2016-09-13 08:58:35 -0700 | [diff] [blame] | 92 | bool 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. |
| 97 | int32_t GetLineNumFromPC(const DexFile* dex_file, ArtMethod* method, uint32_t rel_pc) |
| 98 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 99 | |
| 100 | // Annotations iterator. |
| 101 | class 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_ |