• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "handle.h"
27 #include "obj_ptr.h"
28 #include "verifier_enums.h"
29 
30 namespace art {
31 
32 class CompilerCallbacks;
33 class DexFile;
34 class RootVisitor;
35 class Thread;
36 
37 namespace dex {
38 struct ClassDef;
39 }  // namespace dex
40 
41 namespace mirror {
42 class Class;
43 class DexCache;
44 class ClassLoader;
45 }  // namespace mirror
46 
47 namespace verifier {
48 
49 // Verifier that ensures the complete class is OK.
50 class ClassVerifier {
51  public:
52   // Verify a class. Returns "kNoFailure" on success.
53   static FailureKind VerifyClass(Thread* self,
54                                  ObjPtr<mirror::Class> klass,
55                                  CompilerCallbacks* callbacks,
56                                  bool allow_soft_failures,
57                                  HardFailLogMode log_level,
58                                  uint32_t api_level,
59                                  std::string* error)
60       REQUIRES_SHARED(Locks::mutator_lock_);
61   static FailureKind VerifyClass(Thread* self,
62                                  const DexFile* dex_file,
63                                  Handle<mirror::DexCache> dex_cache,
64                                  Handle<mirror::ClassLoader> class_loader,
65                                  const dex::ClassDef& class_def,
66                                  CompilerCallbacks* callbacks,
67                                  bool allow_soft_failures,
68                                  HardFailLogMode log_level,
69                                  uint32_t api_level,
70                                  std::string* error)
71       REQUIRES_SHARED(Locks::mutator_lock_);
72 
73   static void Init() REQUIRES_SHARED(Locks::mutator_lock_);
74   static void Shutdown();
75 
76   static void VisitStaticRoots(RootVisitor* visitor)
77       REQUIRES_SHARED(Locks::mutator_lock_);
78 
79  private:
80   DISALLOW_COPY_AND_ASSIGN(ClassVerifier);
81 };
82 
83 }  // namespace verifier
84 }  // namespace art
85 
86 #endif  // ART_RUNTIME_VERIFIER_CLASS_VERIFIER_H_
87