xref: /aosp_15_r20/art/runtime/verifier/class_verifier.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
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_VERIFIER_CLASS_VERIFIER_H_
18 #define ART_RUNTIME_VERIFIER_CLASS_VERIFIER_H_
19 
20 #include <string>
21 
22 #include <android-base/macros.h>
23 #include <android-base/thread_annotations.h>
24 
25 #include "base/locks.h"
26 #include "base/macros.h"
27 #include "handle.h"
28 #include "obj_ptr.h"
29 #include "verifier/method_verifier.h"
30 #include "verifier_enums.h"
31 
32 namespace art HIDDEN {
33 
34 class ClassLinker;
35 class CompilerCallbacks;
36 class DexFile;
37 class Thread;
38 
39 namespace dex {
40 struct ClassDef;
41 }  // namespace dex
42 
43 namespace mirror {
44 class Class;
45 class DexCache;
46 class ClassLoader;
47 }  // namespace mirror
48 
49 namespace verifier {
50 
51 class VerifierDeps;
52 
53 // Verifier that ensures the complete class is OK.
54 class ClassVerifier {
55  public:
56   // The main entrypoint for class verification. During AOT, `klass` can be
57   // null.
58   EXPORT static FailureKind VerifyClass(Thread* self,
59                                         VerifierDeps* verifier_deps,
60                                         const DexFile* dex_file,
61                                         Handle<mirror::Class> klass,
62                                         Handle<mirror::DexCache> dex_cache,
63                                         Handle<mirror::ClassLoader> class_loader,
64                                         const dex::ClassDef& class_def,
65                                         CompilerCallbacks* callbacks,
66                                         HardFailLogMode log_level,
67                                         uint32_t api_level,
68                                         std::string* error) REQUIRES_SHARED(Locks::mutator_lock_);
69 
70  private:
71   DISALLOW_COPY_AND_ASSIGN(ClassVerifier);
72 };
73 
74 }  // namespace verifier
75 }  // namespace art
76 
77 #endif  // ART_RUNTIME_VERIFIER_CLASS_VERIFIER_H_
78