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