blob: f243e33e1fe080559b203c2af66a7eeb7b55d294 [file] [log] [blame]
David Brazdilca3c8c32016-09-06 14:04:48 +01001/*
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
Nicolas Geoffray08025182016-10-25 17:20:18 +010017// Test is in compiler, as it uses compiler related code.
18#include "verifier/verifier_deps.h"
David Brazdilca3c8c32016-09-06 14:04:48 +010019
Andreas Gampec6ea7d02017-02-01 16:46:28 -080020#include "art_method-inl.h"
David Brazdilca3c8c32016-09-06 14:04:48 +010021#include "class_linker.h"
Andreas Gamped9911ee2017-03-27 13:27:24 -070022#include "common_compiler_test.h"
David Brazdilca3c8c32016-09-06 14:04:48 +010023#include "compiler_callbacks.h"
Andreas Gamped9911ee2017-03-27 13:27:24 -070024#include "dex/verification_results.h"
25#include "dex/verified_method.h"
Andreas Gampe04c6ab92017-06-08 21:49:14 -070026#include "dex_file-inl.h"
Andreas Gampea5b09a62016-11-17 15:21:22 -080027#include "dex_file_types.h"
Andreas Gamped482e732017-04-24 17:59:09 -070028#include "driver/compiler_driver-inl.h"
Andreas Gamped9911ee2017-03-27 13:27:24 -070029#include "driver/compiler_options.h"
David Brazdilca3c8c32016-09-06 14:04:48 +010030#include "handle_scope-inl.h"
Andreas Gampe6d7abbd2017-04-24 13:19:09 -070031#include "indenter.h"
David Brazdilca3c8c32016-09-06 14:04:48 +010032#include "mirror/class_loader.h"
33#include "runtime.h"
Mathieu Chartier0795f232016-09-27 18:43:30 -070034#include "scoped_thread_state_change-inl.h"
Andreas Gampe6d7abbd2017-04-24 13:19:09 -070035#include "thread.h"
Mathieu Chartier93764b82017-07-17 14:51:53 -070036#include "utils/atomic_dex_ref_map-inl.h"
Andreas Gampe6d7abbd2017-04-24 13:19:09 -070037#include "verifier/method_verifier-inl.h"
David Brazdilca3c8c32016-09-06 14:04:48 +010038
39namespace art {
40namespace verifier {
41
42class VerifierDepsCompilerCallbacks : public CompilerCallbacks {
43 public:
44 explicit VerifierDepsCompilerCallbacks()
45 : CompilerCallbacks(CompilerCallbacks::CallbackMode::kCompileApp),
46 deps_(nullptr) {}
47
48 void MethodVerified(verifier::MethodVerifier* verifier ATTRIBUTE_UNUSED) OVERRIDE {}
49 void ClassRejected(ClassReference ref ATTRIBUTE_UNUSED) OVERRIDE {}
50 bool IsRelocationPossible() OVERRIDE { return false; }
51
52 verifier::VerifierDeps* GetVerifierDeps() const OVERRIDE { return deps_; }
53 void SetVerifierDeps(verifier::VerifierDeps* deps) { deps_ = deps; }
54
55 private:
56 verifier::VerifierDeps* deps_;
57};
58
Nicolas Geoffray08025182016-10-25 17:20:18 +010059class VerifierDepsTest : public CommonCompilerTest {
David Brazdilca3c8c32016-09-06 14:04:48 +010060 public:
61 void SetUpRuntimeOptions(RuntimeOptions* options) {
Nicolas Geoffray08025182016-10-25 17:20:18 +010062 CommonCompilerTest::SetUpRuntimeOptions(options);
David Brazdilca3c8c32016-09-06 14:04:48 +010063 callbacks_.reset(new VerifierDepsCompilerCallbacks());
64 }
65
66 mirror::Class* FindClassByName(const std::string& name, ScopedObjectAccess* soa)
67 REQUIRES_SHARED(Locks::mutator_lock_) {
68 StackHandleScope<1> hs(Thread::Current());
69 Handle<mirror::ClassLoader> class_loader_handle(
Mathieu Chartier0795f232016-09-27 18:43:30 -070070 hs.NewHandle(soa->Decode<mirror::ClassLoader>(class_loader_)));
David Brazdil6f82fbd2016-09-14 11:55:26 +010071 mirror::Class* klass = class_linker_->FindClass(Thread::Current(),
72 name.c_str(),
73 class_loader_handle);
74 if (klass == nullptr) {
75 DCHECK(Thread::Current()->IsExceptionPending());
76 Thread::Current()->ClearException();
77 }
78 return klass;
79 }
80
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +000081 void SetupCompilerDriver() {
82 compiler_options_->boot_image_ = false;
83 compiler_driver_->InitializeThreadPools();
84 }
85
86 void VerifyWithCompilerDriver(verifier::VerifierDeps* deps) {
87 TimingLogger timings("Verify", false, false);
88 // The compiler driver handles the verifier deps in the callbacks, so
89 // remove what this class did for unit testing.
Mathieu Chartier72041a02017-07-14 18:23:25 -070090 if (deps == nullptr) {
91 // Create some verifier deps by default if they are not already specified.
92 deps = new verifier::VerifierDeps(dex_files_);
93 verifier_deps_.reset(deps);
94 }
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +000095 callbacks_->SetVerifierDeps(deps);
96 compiler_driver_->Verify(class_loader_, dex_files_, &timings);
Nicolas Geoffrayb0bbe8e2016-11-19 10:42:37 +000097 callbacks_->SetVerifierDeps(nullptr);
Nicolas Geoffray1d0ae3f2016-12-06 13:40:16 +000098 // Clear entries in the verification results to avoid hitting a DCHECK that
99 // we always succeed inserting a new entry after verifying.
Mathieu Chartierfc8b4222017-09-17 13:44:24 -0700100 AtomicDexRefMap<MethodReference, const VerifiedMethod*>* map =
Nicolas Geoffray1d0ae3f2016-12-06 13:40:16 +0000101 &compiler_driver_->GetVerificationResults()->atomic_verified_methods_;
Mathieu Chartier93764b82017-07-17 14:51:53 -0700102 map->Visit([](const DexFileReference& ref ATTRIBUTE_UNUSED, const VerifiedMethod* method) {
Nicolas Geoffray1d0ae3f2016-12-06 13:40:16 +0000103 delete method;
104 });
105 map->ClearEntries();
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +0000106 }
107
David Brazdil6f82fbd2016-09-14 11:55:26 +0100108 void SetVerifierDeps(const std::vector<const DexFile*>& dex_files) {
109 verifier_deps_.reset(new verifier::VerifierDeps(dex_files));
110 VerifierDepsCompilerCallbacks* callbacks =
111 reinterpret_cast<VerifierDepsCompilerCallbacks*>(callbacks_.get());
112 callbacks->SetVerifierDeps(verifier_deps_.get());
David Brazdilca3c8c32016-09-06 14:04:48 +0100113 }
114
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100115 void LoadDexFile(ScopedObjectAccess* soa, const char* name1, const char* name2 = nullptr)
116 REQUIRES_SHARED(Locks::mutator_lock_) {
117 class_loader_ = (name2 == nullptr) ? LoadDex(name1) : LoadMultiDex(name1, name2);
118 dex_files_ = GetDexFiles(class_loader_);
119 primary_dex_file_ = dex_files_.front();
120
121 SetVerifierDeps(dex_files_);
122 StackHandleScope<1> hs(soa->Self());
123 Handle<mirror::ClassLoader> loader =
124 hs.NewHandle(soa->Decode<mirror::ClassLoader>(class_loader_));
125 for (const DexFile* dex_file : dex_files_) {
126 class_linker_->RegisterDexFile(*dex_file, loader.Get());
127 }
Nicolas Geoffray1d0ae3f2016-12-06 13:40:16 +0000128 for (const DexFile* dex_file : dex_files_) {
129 compiler_driver_->GetVerificationResults()->AddDexFile(dex_file);
130 }
Mathieu Chartier72041a02017-07-14 18:23:25 -0700131 compiler_driver_->SetDexFilesForOatFile(dex_files_);
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100132 }
133
David Brazdilca3c8c32016-09-06 14:04:48 +0100134 void LoadDexFile(ScopedObjectAccess* soa) REQUIRES_SHARED(Locks::mutator_lock_) {
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100135 LoadDexFile(soa, "VerifierDeps");
136 CHECK_EQ(dex_files_.size(), 1u);
David Brazdilca3c8c32016-09-06 14:04:48 +0100137 klass_Main_ = FindClassByName("LMain;", soa);
138 CHECK(klass_Main_ != nullptr);
David Brazdilca3c8c32016-09-06 14:04:48 +0100139 }
140
141 bool VerifyMethod(const std::string& method_name) {
142 ScopedObjectAccess soa(Thread::Current());
143 LoadDexFile(&soa);
144
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100145 StackHandleScope<2> hs(soa.Self());
David Brazdilca3c8c32016-09-06 14:04:48 +0100146 Handle<mirror::ClassLoader> class_loader_handle(
Mathieu Chartier0795f232016-09-27 18:43:30 -0700147 hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader_)));
David Brazdilca3c8c32016-09-06 14:04:48 +0100148 Handle<mirror::DexCache> dex_cache_handle(hs.NewHandle(klass_Main_->GetDexCache()));
149
150 const DexFile::ClassDef* class_def = klass_Main_->GetClassDef();
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100151 const uint8_t* class_data = primary_dex_file_->GetClassData(*class_def);
David Brazdilca3c8c32016-09-06 14:04:48 +0100152 CHECK(class_data != nullptr);
153
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100154 ClassDataItemIterator it(*primary_dex_file_, class_data);
Mathieu Chartiere17cf242017-06-19 11:05:51 -0700155 it.SkipAllFields();
David Brazdilca3c8c32016-09-06 14:04:48 +0100156
157 ArtMethod* method = nullptr;
158 while (it.HasNextDirectMethod()) {
Vladimir Markoba118822017-06-12 15:41:56 +0100159 ArtMethod* resolved_method =
160 class_linker_->ResolveMethod<ClassLinker::ResolveMode::kNoChecks>(
161 *primary_dex_file_,
162 it.GetMemberIndex(),
163 dex_cache_handle,
164 class_loader_handle,
165 nullptr,
166 it.GetMethodInvokeType(*class_def));
David Brazdilca3c8c32016-09-06 14:04:48 +0100167 CHECK(resolved_method != nullptr);
168 if (method_name == resolved_method->GetName()) {
169 method = resolved_method;
170 break;
171 }
172 it.Next();
173 }
174 CHECK(method != nullptr);
175
Nicolas Geoffray340dafa2016-11-18 16:03:10 +0000176 Thread::Current()->SetVerifierDeps(callbacks_->GetVerifierDeps());
David Brazdilca3c8c32016-09-06 14:04:48 +0100177 MethodVerifier verifier(Thread::Current(),
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100178 primary_dex_file_,
David Brazdilca3c8c32016-09-06 14:04:48 +0100179 dex_cache_handle,
180 class_loader_handle,
181 *class_def,
182 it.GetMethodCodeItem(),
183 it.GetMemberIndex(),
184 method,
185 it.GetMethodAccessFlags(),
186 true /* can_load_classes */,
187 true /* allow_soft_failures */,
188 true /* need_precise_constants */,
189 false /* verify to dump */,
190 true /* allow_thread_suspension */);
191 verifier.Verify();
Nicolas Geoffray340dafa2016-11-18 16:03:10 +0000192 Thread::Current()->SetVerifierDeps(nullptr);
David Brazdilca3c8c32016-09-06 14:04:48 +0100193 return !verifier.HasFailures();
194 }
195
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100196 void VerifyDexFile(const char* multidex = nullptr) {
Nicolas Geoffray08025182016-10-25 17:20:18 +0100197 {
198 ScopedObjectAccess soa(Thread::Current());
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100199 LoadDexFile(&soa, "VerifierDeps", multidex);
David Brazdil6f82fbd2016-09-14 11:55:26 +0100200 }
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +0000201 SetupCompilerDriver();
202 VerifyWithCompilerDriver(/* verifier_deps */ nullptr);
David Brazdil6f82fbd2016-09-14 11:55:26 +0100203 }
204
David Brazdilca3c8c32016-09-06 14:04:48 +0100205 bool TestAssignabilityRecording(const std::string& dst,
206 const std::string& src,
207 bool is_strict,
208 bool is_assignable) {
209 ScopedObjectAccess soa(Thread::Current());
210 LoadDexFile(&soa);
David Brazdil6f82fbd2016-09-14 11:55:26 +0100211 mirror::Class* klass_dst = FindClassByName(dst, &soa);
Nicolas Geoffraybdb540d2017-04-19 13:50:34 +0100212 DCHECK(klass_dst != nullptr) << dst;
David Brazdil6f82fbd2016-09-14 11:55:26 +0100213 mirror::Class* klass_src = FindClassByName(src, &soa);
Nicolas Geoffraybdb540d2017-04-19 13:50:34 +0100214 DCHECK(klass_src != nullptr) << src;
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100215 verifier_deps_->AddAssignability(*primary_dex_file_,
David Brazdil6f82fbd2016-09-14 11:55:26 +0100216 klass_dst,
217 klass_src,
David Brazdilca3c8c32016-09-06 14:04:48 +0100218 is_strict,
219 is_assignable);
220 return true;
221 }
222
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +0000223 // Check that the status of classes in `class_loader_` match the
224 // expected status in `deps`.
225 void VerifyClassStatus(const verifier::VerifierDeps& deps) {
226 ScopedObjectAccess soa(Thread::Current());
227 StackHandleScope<2> hs(soa.Self());
228 Handle<mirror::ClassLoader> class_loader_handle(
229 hs.NewHandle(soa.Decode<mirror::ClassLoader>(class_loader_)));
230 MutableHandle<mirror::Class> cls(hs.NewHandle<mirror::Class>(nullptr));
231 for (const DexFile* dex_file : dex_files_) {
Mathieu Chartierbf755fe2017-08-01 13:42:56 -0700232 const std::set<dex::TypeIndex>& unverified_classes = deps.GetUnverifiedClasses(*dex_file);
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +0000233 for (uint32_t i = 0; i < dex_file->NumClassDefs(); ++i) {
234 const DexFile::ClassDef& class_def = dex_file->GetClassDef(i);
235 const char* descriptor = dex_file->GetClassDescriptor(class_def);
236 cls.Assign(class_linker_->FindClass(soa.Self(), descriptor, class_loader_handle));
Andreas Gampefa4333d2017-02-14 11:10:34 -0800237 if (cls == nullptr) {
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +0000238 CHECK(soa.Self()->IsExceptionPending());
239 soa.Self()->ClearException();
Mathieu Chartierbf755fe2017-08-01 13:42:56 -0700240 } else if (unverified_classes.find(class_def.class_idx_) == unverified_classes.end()) {
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +0000241 ASSERT_EQ(cls->GetStatus(), mirror::Class::kStatusVerified);
242 } else {
243 ASSERT_LT(cls->GetStatus(), mirror::Class::kStatusVerified);
244 }
245 }
246 }
247 }
248
Nicolas Geoffray08025182016-10-25 17:20:18 +0100249 bool HasUnverifiedClass(const std::string& cls) {
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +0000250 return HasUnverifiedClass(cls, *primary_dex_file_);
251 }
252
253 bool HasUnverifiedClass(const std::string& cls, const DexFile& dex_file) {
254 const DexFile::TypeId* type_id = dex_file.FindTypeId(cls.c_str());
Nicolas Geoffray08025182016-10-25 17:20:18 +0100255 DCHECK(type_id != nullptr);
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +0000256 dex::TypeIndex index = dex_file.GetIndexForTypeId(*type_id);
Nicolas Geoffray08025182016-10-25 17:20:18 +0100257 for (const auto& dex_dep : verifier_deps_->dex_deps_) {
Andreas Gampea5b09a62016-11-17 15:21:22 -0800258 for (dex::TypeIndex entry : dex_dep.second->unverified_classes_) {
Nicolas Geoffray08025182016-10-25 17:20:18 +0100259 if (index == entry) {
260 return true;
261 }
262 }
263 }
264 return false;
265 }
266
David Brazdilca3c8c32016-09-06 14:04:48 +0100267 // Iterates over all assignability records and tries to find an entry which
268 // matches the expected destination/source pair.
269 bool HasAssignable(const std::string& expected_destination,
270 const std::string& expected_source,
271 bool expected_is_assignable) {
David Brazdilca3c8c32016-09-06 14:04:48 +0100272 for (auto& dex_dep : verifier_deps_->dex_deps_) {
273 const DexFile& dex_file = *dex_dep.first;
274 auto& storage = expected_is_assignable ? dex_dep.second->assignable_types_
275 : dex_dep.second->unassignable_types_;
276 for (auto& entry : storage) {
277 std::string actual_destination =
278 verifier_deps_->GetStringFromId(dex_file, entry.GetDestination());
279 std::string actual_source = verifier_deps_->GetStringFromId(dex_file, entry.GetSource());
280 if ((expected_destination == actual_destination) && (expected_source == actual_source)) {
281 return true;
282 }
283 }
284 }
285 return false;
286 }
287
288 // Iterates over all class resolution records, finds an entry which matches
289 // the given class descriptor and tests its properties.
290 bool HasClass(const std::string& expected_klass,
291 bool expected_resolved,
292 const std::string& expected_access_flags = "") {
David Brazdilca3c8c32016-09-06 14:04:48 +0100293 for (auto& dex_dep : verifier_deps_->dex_deps_) {
294 for (auto& entry : dex_dep.second->classes_) {
295 if (expected_resolved != entry.IsResolved()) {
296 continue;
297 }
298
299 std::string actual_klass = dex_dep.first->StringByTypeIdx(entry.GetDexTypeIndex());
300 if (expected_klass != actual_klass) {
301 continue;
302 }
303
304 if (expected_resolved) {
305 // Test access flags. Note that PrettyJavaAccessFlags always appends
306 // a space after the modifiers. Add it to the expected access flags.
307 std::string actual_access_flags = PrettyJavaAccessFlags(entry.GetAccessFlags());
308 if (expected_access_flags + " " != actual_access_flags) {
309 continue;
310 }
311 }
312
313 return true;
314 }
315 }
316 return false;
317 }
318
319 // Iterates over all field resolution records, finds an entry which matches
320 // the given field class+name+type and tests its properties.
321 bool HasField(const std::string& expected_klass,
322 const std::string& expected_name,
323 const std::string& expected_type,
324 bool expected_resolved,
325 const std::string& expected_access_flags = "",
326 const std::string& expected_decl_klass = "") {
David Brazdilca3c8c32016-09-06 14:04:48 +0100327 for (auto& dex_dep : verifier_deps_->dex_deps_) {
328 for (auto& entry : dex_dep.second->fields_) {
329 if (expected_resolved != entry.IsResolved()) {
330 continue;
331 }
332
333 const DexFile::FieldId& field_id = dex_dep.first->GetFieldId(entry.GetDexFieldIndex());
334
335 std::string actual_klass = dex_dep.first->StringByTypeIdx(field_id.class_idx_);
336 if (expected_klass != actual_klass) {
337 continue;
338 }
339
340 std::string actual_name = dex_dep.first->StringDataByIdx(field_id.name_idx_);
341 if (expected_name != actual_name) {
342 continue;
343 }
344
345 std::string actual_type = dex_dep.first->StringByTypeIdx(field_id.type_idx_);
346 if (expected_type != actual_type) {
347 continue;
348 }
349
350 if (expected_resolved) {
351 // Test access flags. Note that PrettyJavaAccessFlags always appends
352 // a space after the modifiers. Add it to the expected access flags.
353 std::string actual_access_flags = PrettyJavaAccessFlags(entry.GetAccessFlags());
354 if (expected_access_flags + " " != actual_access_flags) {
355 continue;
356 }
357
358 std::string actual_decl_klass = verifier_deps_->GetStringFromId(
359 *dex_dep.first, entry.GetDeclaringClassIndex());
360 if (expected_decl_klass != actual_decl_klass) {
361 continue;
362 }
363 }
364
365 return true;
366 }
367 }
368 return false;
369 }
370
371 // Iterates over all method resolution records, finds an entry which matches
372 // the given field kind+class+name+signature and tests its properties.
Vladimir Markoba118822017-06-12 15:41:56 +0100373 bool HasMethod(const std::string& expected_klass,
David Brazdilca3c8c32016-09-06 14:04:48 +0100374 const std::string& expected_name,
375 const std::string& expected_signature,
376 bool expected_resolved,
377 const std::string& expected_access_flags = "",
378 const std::string& expected_decl_klass = "") {
David Brazdilca3c8c32016-09-06 14:04:48 +0100379 for (auto& dex_dep : verifier_deps_->dex_deps_) {
Vladimir Markoba118822017-06-12 15:41:56 +0100380 for (const VerifierDeps::MethodResolution& entry : dex_dep.second->methods_) {
David Brazdilca3c8c32016-09-06 14:04:48 +0100381 if (expected_resolved != entry.IsResolved()) {
382 continue;
383 }
384
385 const DexFile::MethodId& method_id = dex_dep.first->GetMethodId(entry.GetDexMethodIndex());
386
387 std::string actual_klass = dex_dep.first->StringByTypeIdx(method_id.class_idx_);
388 if (expected_klass != actual_klass) {
389 continue;
390 }
391
392 std::string actual_name = dex_dep.first->StringDataByIdx(method_id.name_idx_);
393 if (expected_name != actual_name) {
394 continue;
395 }
396
397 std::string actual_signature = dex_dep.first->GetMethodSignature(method_id).ToString();
398 if (expected_signature != actual_signature) {
399 continue;
400 }
401
402 if (expected_resolved) {
403 // Test access flags. Note that PrettyJavaAccessFlags always appends
404 // a space after the modifiers. Add it to the expected access flags.
405 std::string actual_access_flags = PrettyJavaAccessFlags(entry.GetAccessFlags());
406 if (expected_access_flags + " " != actual_access_flags) {
407 continue;
408 }
409
410 std::string actual_decl_klass = verifier_deps_->GetStringFromId(
411 *dex_dep.first, entry.GetDeclaringClassIndex());
412 if (expected_decl_klass != actual_decl_klass) {
413 continue;
414 }
415 }
416
417 return true;
418 }
419 }
420 return false;
421 }
422
David Brazdil6f82fbd2016-09-14 11:55:26 +0100423 size_t NumberOfCompiledDexFiles() {
David Brazdil6f82fbd2016-09-14 11:55:26 +0100424 return verifier_deps_->dex_deps_.size();
425 }
426
427 size_t HasEachKindOfRecord() {
David Brazdil6f82fbd2016-09-14 11:55:26 +0100428 bool has_strings = false;
429 bool has_assignability = false;
430 bool has_classes = false;
431 bool has_fields = false;
432 bool has_methods = false;
Nicolas Geoffray08025182016-10-25 17:20:18 +0100433 bool has_unverified_classes = false;
David Brazdil6f82fbd2016-09-14 11:55:26 +0100434
435 for (auto& entry : verifier_deps_->dex_deps_) {
436 has_strings |= !entry.second->strings_.empty();
437 has_assignability |= !entry.second->assignable_types_.empty();
438 has_assignability |= !entry.second->unassignable_types_.empty();
439 has_classes |= !entry.second->classes_.empty();
440 has_fields |= !entry.second->fields_.empty();
Vladimir Markoba118822017-06-12 15:41:56 +0100441 has_methods |= !entry.second->methods_.empty();
Nicolas Geoffray08025182016-10-25 17:20:18 +0100442 has_unverified_classes |= !entry.second->unverified_classes_.empty();
David Brazdil6f82fbd2016-09-14 11:55:26 +0100443 }
444
Nicolas Geoffray08025182016-10-25 17:20:18 +0100445 return has_strings &&
446 has_assignability &&
447 has_classes &&
448 has_fields &&
449 has_methods &&
450 has_unverified_classes;
David Brazdil6f82fbd2016-09-14 11:55:26 +0100451 }
452
David Brazdilca3c8c32016-09-06 14:04:48 +0100453 std::unique_ptr<verifier::VerifierDeps> verifier_deps_;
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100454 std::vector<const DexFile*> dex_files_;
455 const DexFile* primary_dex_file_;
David Brazdilca3c8c32016-09-06 14:04:48 +0100456 jobject class_loader_;
457 mirror::Class* klass_Main_;
458};
459
460TEST_F(VerifierDepsTest, StringToId) {
461 ScopedObjectAccess soa(Thread::Current());
462 LoadDexFile(&soa);
463
Andreas Gampe8a0128a2016-11-28 07:38:35 -0800464 dex::StringIndex id_Main1 = verifier_deps_->GetIdFromString(*primary_dex_file_, "LMain;");
465 ASSERT_LT(id_Main1.index_, primary_dex_file_->NumStringIds());
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100466 ASSERT_EQ("LMain;", verifier_deps_->GetStringFromId(*primary_dex_file_, id_Main1));
David Brazdilca3c8c32016-09-06 14:04:48 +0100467
Andreas Gampe8a0128a2016-11-28 07:38:35 -0800468 dex::StringIndex id_Main2 = verifier_deps_->GetIdFromString(*primary_dex_file_, "LMain;");
469 ASSERT_LT(id_Main2.index_, primary_dex_file_->NumStringIds());
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100470 ASSERT_EQ("LMain;", verifier_deps_->GetStringFromId(*primary_dex_file_, id_Main2));
David Brazdilca3c8c32016-09-06 14:04:48 +0100471
Andreas Gampe8a0128a2016-11-28 07:38:35 -0800472 dex::StringIndex id_Lorem1 = verifier_deps_->GetIdFromString(*primary_dex_file_, "Lorem ipsum");
473 ASSERT_GE(id_Lorem1.index_, primary_dex_file_->NumStringIds());
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100474 ASSERT_EQ("Lorem ipsum", verifier_deps_->GetStringFromId(*primary_dex_file_, id_Lorem1));
David Brazdilca3c8c32016-09-06 14:04:48 +0100475
Andreas Gampe8a0128a2016-11-28 07:38:35 -0800476 dex::StringIndex id_Lorem2 = verifier_deps_->GetIdFromString(*primary_dex_file_, "Lorem ipsum");
477 ASSERT_GE(id_Lorem2.index_, primary_dex_file_->NumStringIds());
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +0100478 ASSERT_EQ("Lorem ipsum", verifier_deps_->GetStringFromId(*primary_dex_file_, id_Lorem2));
David Brazdilca3c8c32016-09-06 14:04:48 +0100479
480 ASSERT_EQ(id_Main1, id_Main2);
481 ASSERT_EQ(id_Lorem1, id_Lorem2);
482 ASSERT_NE(id_Main1, id_Lorem1);
483}
484
485TEST_F(VerifierDepsTest, Assignable_BothInBoot) {
486 ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "Ljava/util/TimeZone;",
487 /* src */ "Ljava/util/SimpleTimeZone;",
488 /* is_strict */ true,
489 /* is_assignable */ true));
490 ASSERT_TRUE(HasAssignable("Ljava/util/TimeZone;", "Ljava/util/SimpleTimeZone;", true));
491}
492
493TEST_F(VerifierDepsTest, Assignable_DestinationInBoot1) {
494 ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "Ljava/net/Socket;",
495 /* src */ "LMySSLSocket;",
496 /* is_strict */ true,
497 /* is_assignable */ true));
Nicolas Geoffray119e8462016-12-21 10:29:43 +0000498 ASSERT_TRUE(HasAssignable("Ljava/net/Socket;", "Ljavax/net/ssl/SSLSocket;", true));
David Brazdilca3c8c32016-09-06 14:04:48 +0100499}
500
501TEST_F(VerifierDepsTest, Assignable_DestinationInBoot2) {
502 ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "Ljava/util/TimeZone;",
503 /* src */ "LMySimpleTimeZone;",
504 /* is_strict */ true,
505 /* is_assignable */ true));
Nicolas Geoffray119e8462016-12-21 10:29:43 +0000506 ASSERT_TRUE(HasAssignable("Ljava/util/TimeZone;", "Ljava/util/SimpleTimeZone;", true));
David Brazdilca3c8c32016-09-06 14:04:48 +0100507}
508
509TEST_F(VerifierDepsTest, Assignable_DestinationInBoot3) {
510 ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "Ljava/util/Collection;",
511 /* src */ "LMyThreadSet;",
512 /* is_strict */ true,
513 /* is_assignable */ true));
Nicolas Geoffray0e2fe0f2016-12-21 16:54:52 +0000514 ASSERT_TRUE(HasAssignable("Ljava/util/Collection;", "Ljava/util/Set;", true));
David Brazdilca3c8c32016-09-06 14:04:48 +0100515}
516
517TEST_F(VerifierDepsTest, Assignable_BothArrays_Resolved) {
518 ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "[[Ljava/util/TimeZone;",
519 /* src */ "[[Ljava/util/SimpleTimeZone;",
520 /* is_strict */ true,
521 /* is_assignable */ true));
522 // If the component types of both arrays are resolved, we optimize the list of
523 // dependencies by recording a dependency on the component types.
524 ASSERT_FALSE(HasAssignable("[[Ljava/util/TimeZone;", "[[Ljava/util/SimpleTimeZone;", true));
525 ASSERT_FALSE(HasAssignable("[Ljava/util/TimeZone;", "[Ljava/util/SimpleTimeZone;", true));
526 ASSERT_TRUE(HasAssignable("Ljava/util/TimeZone;", "Ljava/util/SimpleTimeZone;", true));
527}
528
David Brazdilca3c8c32016-09-06 14:04:48 +0100529TEST_F(VerifierDepsTest, NotAssignable_BothInBoot) {
530 ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "Ljava/lang/Exception;",
531 /* src */ "Ljava/util/SimpleTimeZone;",
532 /* is_strict */ true,
533 /* is_assignable */ false));
534 ASSERT_TRUE(HasAssignable("Ljava/lang/Exception;", "Ljava/util/SimpleTimeZone;", false));
535}
536
537TEST_F(VerifierDepsTest, NotAssignable_DestinationInBoot1) {
538 ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "Ljava/lang/Exception;",
539 /* src */ "LMySSLSocket;",
540 /* is_strict */ true,
541 /* is_assignable */ false));
Nicolas Geoffray119e8462016-12-21 10:29:43 +0000542 ASSERT_TRUE(HasAssignable("Ljava/lang/Exception;", "Ljavax/net/ssl/SSLSocket;", false));
David Brazdilca3c8c32016-09-06 14:04:48 +0100543}
544
545TEST_F(VerifierDepsTest, NotAssignable_DestinationInBoot2) {
546 ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "Ljava/lang/Exception;",
547 /* src */ "LMySimpleTimeZone;",
548 /* is_strict */ true,
549 /* is_assignable */ false));
Nicolas Geoffray119e8462016-12-21 10:29:43 +0000550 ASSERT_TRUE(HasAssignable("Ljava/lang/Exception;", "Ljava/util/SimpleTimeZone;", false));
David Brazdilca3c8c32016-09-06 14:04:48 +0100551}
552
553TEST_F(VerifierDepsTest, NotAssignable_BothArrays) {
554 ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "[Ljava/lang/Exception;",
555 /* src */ "[Ljava/util/SimpleTimeZone;",
556 /* is_strict */ true,
557 /* is_assignable */ false));
558 ASSERT_TRUE(HasAssignable("Ljava/lang/Exception;", "Ljava/util/SimpleTimeZone;", false));
559}
560
561TEST_F(VerifierDepsTest, ArgumentType_ResolvedClass) {
562 ASSERT_TRUE(VerifyMethod("ArgumentType_ResolvedClass"));
563 ASSERT_TRUE(HasClass("Ljava/lang/Thread;", true, "public"));
564}
565
David Brazdilca3c8c32016-09-06 14:04:48 +0100566TEST_F(VerifierDepsTest, ArgumentType_UnresolvedClass) {
567 ASSERT_TRUE(VerifyMethod("ArgumentType_UnresolvedClass"));
568 ASSERT_TRUE(HasClass("LUnresolvedClass;", false));
569}
570
571TEST_F(VerifierDepsTest, ArgumentType_UnresolvedSuper) {
572 ASSERT_TRUE(VerifyMethod("ArgumentType_UnresolvedSuper"));
573 ASSERT_TRUE(HasClass("LMySetWithUnresolvedSuper;", false));
574}
575
576TEST_F(VerifierDepsTest, ReturnType_Reference) {
577 ASSERT_TRUE(VerifyMethod("ReturnType_Reference"));
578 ASSERT_TRUE(HasAssignable("Ljava/lang/Throwable;", "Ljava/lang/IllegalStateException;", true));
579}
580
581TEST_F(VerifierDepsTest, ReturnType_Array) {
582 ASSERT_FALSE(VerifyMethod("ReturnType_Array"));
583 ASSERT_TRUE(HasAssignable("Ljava/lang/Integer;", "Ljava/lang/IllegalStateException;", false));
584}
585
586TEST_F(VerifierDepsTest, InvokeArgumentType) {
587 ASSERT_TRUE(VerifyMethod("InvokeArgumentType"));
588 ASSERT_TRUE(HasClass("Ljava/text/SimpleDateFormat;", true, "public"));
589 ASSERT_TRUE(HasClass("Ljava/util/SimpleTimeZone;", true, "public"));
Vladimir Markoba118822017-06-12 15:41:56 +0100590 ASSERT_TRUE(HasMethod("Ljava/text/SimpleDateFormat;",
David Brazdilca3c8c32016-09-06 14:04:48 +0100591 "setTimeZone",
592 "(Ljava/util/TimeZone;)V",
Vladimir Markoba118822017-06-12 15:41:56 +0100593 /* expect_resolved */ true,
David Brazdilca3c8c32016-09-06 14:04:48 +0100594 "public",
595 "Ljava/text/DateFormat;"));
596 ASSERT_TRUE(HasAssignable("Ljava/util/TimeZone;", "Ljava/util/SimpleTimeZone;", true));
597}
598
599TEST_F(VerifierDepsTest, MergeTypes_RegisterLines) {
600 ASSERT_TRUE(VerifyMethod("MergeTypes_RegisterLines"));
Nicolas Geoffray119e8462016-12-21 10:29:43 +0000601 ASSERT_TRUE(HasAssignable("Ljava/lang/Exception;", "Ljava/net/SocketTimeoutException;", true));
David Brazdilca3c8c32016-09-06 14:04:48 +0100602 ASSERT_TRUE(HasAssignable(
603 "Ljava/lang/Exception;", "Ljava/util/concurrent/TimeoutException;", true));
604}
605
606TEST_F(VerifierDepsTest, MergeTypes_IfInstanceOf) {
607 ASSERT_TRUE(VerifyMethod("MergeTypes_IfInstanceOf"));
608 ASSERT_TRUE(HasAssignable("Ljava/lang/Exception;", "Ljava/net/SocketTimeoutException;", true));
609 ASSERT_TRUE(HasAssignable(
610 "Ljava/lang/Exception;", "Ljava/util/concurrent/TimeoutException;", true));
611 ASSERT_TRUE(HasAssignable("Ljava/net/SocketTimeoutException;", "Ljava/lang/Exception;", false));
612}
613
614TEST_F(VerifierDepsTest, MergeTypes_Unresolved) {
615 ASSERT_TRUE(VerifyMethod("MergeTypes_Unresolved"));
616 ASSERT_TRUE(HasAssignable("Ljava/lang/Exception;", "Ljava/net/SocketTimeoutException;", true));
617 ASSERT_TRUE(HasAssignable(
618 "Ljava/lang/Exception;", "Ljava/util/concurrent/TimeoutException;", true));
619}
620
621TEST_F(VerifierDepsTest, ConstClass_Resolved) {
622 ASSERT_TRUE(VerifyMethod("ConstClass_Resolved"));
623 ASSERT_TRUE(HasClass("Ljava/lang/IllegalStateException;", true, "public"));
624}
625
626TEST_F(VerifierDepsTest, ConstClass_Unresolved) {
Andreas Gampe629be512017-08-25 17:09:32 -0700627 ASSERT_FALSE(VerifyMethod("ConstClass_Unresolved"));
David Brazdilca3c8c32016-09-06 14:04:48 +0100628 ASSERT_TRUE(HasClass("LUnresolvedClass;", false));
629}
630
631TEST_F(VerifierDepsTest, CheckCast_Resolved) {
632 ASSERT_TRUE(VerifyMethod("CheckCast_Resolved"));
633 ASSERT_TRUE(HasClass("Ljava/lang/IllegalStateException;", true, "public"));
634}
635
636TEST_F(VerifierDepsTest, CheckCast_Unresolved) {
Andreas Gampe629be512017-08-25 17:09:32 -0700637 ASSERT_FALSE(VerifyMethod("CheckCast_Unresolved"));
David Brazdilca3c8c32016-09-06 14:04:48 +0100638 ASSERT_TRUE(HasClass("LUnresolvedClass;", false));
639}
640
641TEST_F(VerifierDepsTest, InstanceOf_Resolved) {
642 ASSERT_TRUE(VerifyMethod("InstanceOf_Resolved"));
643 ASSERT_TRUE(HasClass("Ljava/lang/IllegalStateException;", true, "public"));
644}
645
646TEST_F(VerifierDepsTest, InstanceOf_Unresolved) {
Andreas Gampe629be512017-08-25 17:09:32 -0700647 ASSERT_FALSE(VerifyMethod("InstanceOf_Unresolved"));
David Brazdilca3c8c32016-09-06 14:04:48 +0100648 ASSERT_TRUE(HasClass("LUnresolvedClass;", false));
649}
650
651TEST_F(VerifierDepsTest, NewInstance_Resolved) {
652 ASSERT_TRUE(VerifyMethod("NewInstance_Resolved"));
653 ASSERT_TRUE(HasClass("Ljava/lang/IllegalStateException;", true, "public"));
654}
655
656TEST_F(VerifierDepsTest, NewInstance_Unresolved) {
Andreas Gampe629be512017-08-25 17:09:32 -0700657 ASSERT_FALSE(VerifyMethod("NewInstance_Unresolved"));
David Brazdilca3c8c32016-09-06 14:04:48 +0100658 ASSERT_TRUE(HasClass("LUnresolvedClass;", false));
659}
660
David Brazdilca3c8c32016-09-06 14:04:48 +0100661TEST_F(VerifierDepsTest, NewArray_Unresolved) {
Andreas Gampe629be512017-08-25 17:09:32 -0700662 ASSERT_FALSE(VerifyMethod("NewArray_Unresolved"));
David Brazdilca3c8c32016-09-06 14:04:48 +0100663 ASSERT_TRUE(HasClass("[LUnresolvedClass;", false));
664}
665
666TEST_F(VerifierDepsTest, Throw) {
667 ASSERT_TRUE(VerifyMethod("Throw"));
668 ASSERT_TRUE(HasAssignable("Ljava/lang/Throwable;", "Ljava/lang/IllegalStateException;", true));
669}
670
671TEST_F(VerifierDepsTest, MoveException_Resolved) {
672 ASSERT_TRUE(VerifyMethod("MoveException_Resolved"));
673 ASSERT_TRUE(HasClass("Ljava/io/InterruptedIOException;", true, "public"));
674 ASSERT_TRUE(HasClass("Ljava/net/SocketTimeoutException;", true, "public"));
675 ASSERT_TRUE(HasClass("Ljava/util/zip/ZipException;", true, "public"));
676
677 // Testing that all exception types are assignable to Throwable.
678 ASSERT_TRUE(HasAssignable("Ljava/lang/Throwable;", "Ljava/io/InterruptedIOException;", true));
679 ASSERT_TRUE(HasAssignable("Ljava/lang/Throwable;", "Ljava/net/SocketTimeoutException;", true));
680 ASSERT_TRUE(HasAssignable("Ljava/lang/Throwable;", "Ljava/util/zip/ZipException;", true));
681
682 // Testing that the merge type is assignable to Throwable.
683 ASSERT_TRUE(HasAssignable("Ljava/lang/Throwable;", "Ljava/io/IOException;", true));
684
685 // Merging of exception types.
686 ASSERT_TRUE(HasAssignable("Ljava/io/IOException;", "Ljava/io/InterruptedIOException;", true));
687 ASSERT_TRUE(HasAssignable("Ljava/io/IOException;", "Ljava/util/zip/ZipException;", true));
688 ASSERT_TRUE(HasAssignable(
689 "Ljava/io/InterruptedIOException;", "Ljava/net/SocketTimeoutException;", true));
690}
691
692TEST_F(VerifierDepsTest, MoveException_Unresolved) {
693 ASSERT_FALSE(VerifyMethod("MoveException_Unresolved"));
694 ASSERT_TRUE(HasClass("LUnresolvedException;", false));
695}
696
697TEST_F(VerifierDepsTest, StaticField_Resolved_DeclaredInReferenced) {
698 ASSERT_TRUE(VerifyMethod("StaticField_Resolved_DeclaredInReferenced"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000699 ASSERT_TRUE(HasClass("Ljava/lang/System;", true, "public"));
David Brazdilca3c8c32016-09-06 14:04:48 +0100700 ASSERT_TRUE(HasField("Ljava/lang/System;",
701 "out",
702 "Ljava/io/PrintStream;",
703 true,
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000704 "public static",
David Brazdilca3c8c32016-09-06 14:04:48 +0100705 "Ljava/lang/System;"));
706}
707
708TEST_F(VerifierDepsTest, StaticField_Resolved_DeclaredInSuperclass1) {
709 ASSERT_TRUE(VerifyMethod("StaticField_Resolved_DeclaredInSuperclass1"));
710 ASSERT_TRUE(HasClass("Ljava/util/SimpleTimeZone;", true, "public"));
711 ASSERT_TRUE(HasField(
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000712 "Ljava/util/SimpleTimeZone;", "LONG", "I", true, "public static", "Ljava/util/TimeZone;"));
David Brazdilca3c8c32016-09-06 14:04:48 +0100713}
714
715TEST_F(VerifierDepsTest, StaticField_Resolved_DeclaredInSuperclass2) {
716 ASSERT_TRUE(VerifyMethod("StaticField_Resolved_DeclaredInSuperclass2"));
717 ASSERT_TRUE(HasField(
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000718 "LMySimpleTimeZone;", "SHORT", "I", true, "public static", "Ljava/util/TimeZone;"));
David Brazdilca3c8c32016-09-06 14:04:48 +0100719}
720
721TEST_F(VerifierDepsTest, StaticField_Resolved_DeclaredInInterface1) {
722 ASSERT_TRUE(VerifyMethod("StaticField_Resolved_DeclaredInInterface1"));
723 ASSERT_TRUE(HasClass("Ljavax/xml/transform/dom/DOMResult;", true, "public"));
724 ASSERT_TRUE(HasField("Ljavax/xml/transform/dom/DOMResult;",
725 "PI_ENABLE_OUTPUT_ESCAPING",
726 "Ljava/lang/String;",
727 true,
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000728 "public static",
David Brazdilca3c8c32016-09-06 14:04:48 +0100729 "Ljavax/xml/transform/Result;"));
730}
731
732TEST_F(VerifierDepsTest, StaticField_Resolved_DeclaredInInterface2) {
733 ASSERT_TRUE(VerifyMethod("StaticField_Resolved_DeclaredInInterface2"));
734 ASSERT_TRUE(HasField("LMyDOMResult;",
735 "PI_ENABLE_OUTPUT_ESCAPING",
736 "Ljava/lang/String;",
737 true,
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000738 "public static",
David Brazdilca3c8c32016-09-06 14:04:48 +0100739 "Ljavax/xml/transform/Result;"));
740}
741
742TEST_F(VerifierDepsTest, StaticField_Resolved_DeclaredInInterface3) {
743 ASSERT_TRUE(VerifyMethod("StaticField_Resolved_DeclaredInInterface3"));
744 ASSERT_TRUE(HasField("LMyResult;",
745 "PI_ENABLE_OUTPUT_ESCAPING",
746 "Ljava/lang/String;",
747 true,
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000748 "public static",
David Brazdilca3c8c32016-09-06 14:04:48 +0100749 "Ljavax/xml/transform/Result;"));
750}
751
752TEST_F(VerifierDepsTest, StaticField_Resolved_DeclaredInInterface4) {
753 ASSERT_TRUE(VerifyMethod("StaticField_Resolved_DeclaredInInterface4"));
754 ASSERT_TRUE(HasField("LMyDocument;",
755 "ELEMENT_NODE",
756 "S",
757 true,
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000758 "public static",
David Brazdilca3c8c32016-09-06 14:04:48 +0100759 "Lorg/w3c/dom/Node;"));
760}
761
762TEST_F(VerifierDepsTest, StaticField_Unresolved_ReferrerInBoot) {
763 ASSERT_TRUE(VerifyMethod("StaticField_Unresolved_ReferrerInBoot"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000764 ASSERT_TRUE(HasClass("Ljava/util/TimeZone;", true, "public"));
David Brazdilca3c8c32016-09-06 14:04:48 +0100765 ASSERT_TRUE(HasField("Ljava/util/TimeZone;", "x", "I", false));
766}
767
768TEST_F(VerifierDepsTest, StaticField_Unresolved_ReferrerInDex) {
769 ASSERT_TRUE(VerifyMethod("StaticField_Unresolved_ReferrerInDex"));
770 ASSERT_TRUE(HasField("LMyThreadSet;", "x", "I", false));
771}
772
773TEST_F(VerifierDepsTest, InstanceField_Resolved_DeclaredInReferenced) {
774 ASSERT_TRUE(VerifyMethod("InstanceField_Resolved_DeclaredInReferenced"));
775 ASSERT_TRUE(HasClass("Ljava/io/InterruptedIOException;", true, "public"));
776 ASSERT_TRUE(HasField("Ljava/io/InterruptedIOException;",
777 "bytesTransferred",
778 "I",
779 true,
780 "public",
781 "Ljava/io/InterruptedIOException;"));
782 ASSERT_TRUE(HasAssignable(
Nicolas Geoffray119e8462016-12-21 10:29:43 +0000783 "Ljava/io/InterruptedIOException;", "Ljava/net/SocketTimeoutException;", true));
David Brazdilca3c8c32016-09-06 14:04:48 +0100784}
785
786TEST_F(VerifierDepsTest, InstanceField_Resolved_DeclaredInSuperclass1) {
787 ASSERT_TRUE(VerifyMethod("InstanceField_Resolved_DeclaredInSuperclass1"));
788 ASSERT_TRUE(HasClass("Ljava/net/SocketTimeoutException;", true, "public"));
789 ASSERT_TRUE(HasField("Ljava/net/SocketTimeoutException;",
790 "bytesTransferred",
791 "I",
792 true,
793 "public",
794 "Ljava/io/InterruptedIOException;"));
795 ASSERT_TRUE(HasAssignable(
Nicolas Geoffray119e8462016-12-21 10:29:43 +0000796 "Ljava/io/InterruptedIOException;", "Ljava/net/SocketTimeoutException;", true));
David Brazdilca3c8c32016-09-06 14:04:48 +0100797}
798
799TEST_F(VerifierDepsTest, InstanceField_Resolved_DeclaredInSuperclass2) {
800 ASSERT_TRUE(VerifyMethod("InstanceField_Resolved_DeclaredInSuperclass2"));
801 ASSERT_TRUE(HasField("LMySocketTimeoutException;",
802 "bytesTransferred",
803 "I",
804 true,
805 "public",
806 "Ljava/io/InterruptedIOException;"));
807 ASSERT_TRUE(HasAssignable(
Nicolas Geoffray119e8462016-12-21 10:29:43 +0000808 "Ljava/io/InterruptedIOException;", "Ljava/net/SocketTimeoutException;", true));
David Brazdilca3c8c32016-09-06 14:04:48 +0100809}
810
811TEST_F(VerifierDepsTest, InstanceField_Unresolved_ReferrerInBoot) {
812 ASSERT_TRUE(VerifyMethod("InstanceField_Unresolved_ReferrerInBoot"));
813 ASSERT_TRUE(HasClass("Ljava/io/InterruptedIOException;", true, "public"));
814 ASSERT_TRUE(HasField("Ljava/io/InterruptedIOException;", "x", "I", false));
815}
816
817TEST_F(VerifierDepsTest, InstanceField_Unresolved_ReferrerInDex) {
818 ASSERT_TRUE(VerifyMethod("InstanceField_Unresolved_ReferrerInDex"));
819 ASSERT_TRUE(HasField("LMyThreadSet;", "x", "I", false));
820}
821
822TEST_F(VerifierDepsTest, InvokeStatic_Resolved_DeclaredInReferenced) {
823 ASSERT_TRUE(VerifyMethod("InvokeStatic_Resolved_DeclaredInReferenced"));
824 ASSERT_TRUE(HasClass("Ljava/net/Socket;", true, "public"));
Vladimir Markoba118822017-06-12 15:41:56 +0100825 ASSERT_TRUE(HasMethod("Ljava/net/Socket;",
David Brazdilca3c8c32016-09-06 14:04:48 +0100826 "setSocketImplFactory",
827 "(Ljava/net/SocketImplFactory;)V",
Vladimir Markoba118822017-06-12 15:41:56 +0100828 /* expect_resolved */ true,
David Brazdilca3c8c32016-09-06 14:04:48 +0100829 "public static",
830 "Ljava/net/Socket;"));
831}
832
833TEST_F(VerifierDepsTest, InvokeStatic_Resolved_DeclaredInSuperclass1) {
834 ASSERT_TRUE(VerifyMethod("InvokeStatic_Resolved_DeclaredInSuperclass1"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000835 ASSERT_TRUE(HasClass("Ljavax/net/ssl/SSLSocket;", true, "public"));
Vladimir Markoba118822017-06-12 15:41:56 +0100836 ASSERT_TRUE(HasMethod("Ljavax/net/ssl/SSLSocket;",
David Brazdilca3c8c32016-09-06 14:04:48 +0100837 "setSocketImplFactory",
838 "(Ljava/net/SocketImplFactory;)V",
Vladimir Markoba118822017-06-12 15:41:56 +0100839 /* expect_resolved */ true,
David Brazdilca3c8c32016-09-06 14:04:48 +0100840 "public static",
841 "Ljava/net/Socket;"));
842}
843
844TEST_F(VerifierDepsTest, InvokeStatic_Resolved_DeclaredInSuperclass2) {
845 ASSERT_TRUE(VerifyMethod("InvokeStatic_Resolved_DeclaredInSuperclass2"));
Vladimir Markoba118822017-06-12 15:41:56 +0100846 ASSERT_TRUE(HasMethod("LMySSLSocket;",
David Brazdilca3c8c32016-09-06 14:04:48 +0100847 "setSocketImplFactory",
848 "(Ljava/net/SocketImplFactory;)V",
Vladimir Markoba118822017-06-12 15:41:56 +0100849 /* expect_resolved */ true,
David Brazdilca3c8c32016-09-06 14:04:48 +0100850 "public static",
851 "Ljava/net/Socket;"));
852}
853
854TEST_F(VerifierDepsTest, InvokeStatic_DeclaredInInterface1) {
855 ASSERT_TRUE(VerifyMethod("InvokeStatic_DeclaredInInterface1"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000856 ASSERT_TRUE(HasClass("Ljava/util/Map$Entry;", true, "public interface"));
Vladimir Markoba118822017-06-12 15:41:56 +0100857 ASSERT_TRUE(HasMethod("Ljava/util/Map$Entry;",
David Brazdilca3c8c32016-09-06 14:04:48 +0100858 "comparingByKey",
859 "()Ljava/util/Comparator;",
Vladimir Markoba118822017-06-12 15:41:56 +0100860 /* expect_resolved */ true,
David Brazdilca3c8c32016-09-06 14:04:48 +0100861 "public static",
862 "Ljava/util/Map$Entry;"));
863}
864
865TEST_F(VerifierDepsTest, InvokeStatic_DeclaredInInterface2) {
866 ASSERT_FALSE(VerifyMethod("InvokeStatic_DeclaredInInterface2"));
867 ASSERT_TRUE(HasClass("Ljava/util/AbstractMap$SimpleEntry;", true, "public"));
Vladimir Markoba118822017-06-12 15:41:56 +0100868 ASSERT_TRUE(HasMethod("Ljava/util/AbstractMap$SimpleEntry;",
David Brazdilca3c8c32016-09-06 14:04:48 +0100869 "comparingByKey",
870 "()Ljava/util/Comparator;",
Vladimir Markoba118822017-06-12 15:41:56 +0100871 /* expect_resolved */ false));
David Brazdilca3c8c32016-09-06 14:04:48 +0100872}
873
874TEST_F(VerifierDepsTest, InvokeStatic_Unresolved1) {
875 ASSERT_FALSE(VerifyMethod("InvokeStatic_Unresolved1"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000876 ASSERT_TRUE(HasClass("Ljavax/net/ssl/SSLSocket;", true, "public"));
Vladimir Markoba118822017-06-12 15:41:56 +0100877 ASSERT_TRUE(HasMethod("Ljavax/net/ssl/SSLSocket;",
878 "x",
879 "()V",
880 /* expect_resolved */ false));
David Brazdilca3c8c32016-09-06 14:04:48 +0100881}
882
883TEST_F(VerifierDepsTest, InvokeStatic_Unresolved2) {
884 ASSERT_FALSE(VerifyMethod("InvokeStatic_Unresolved2"));
Vladimir Markoba118822017-06-12 15:41:56 +0100885 ASSERT_TRUE(HasMethod("LMySSLSocket;",
886 "x",
887 "()V",
888 /* expect_resolved */ false));
David Brazdilca3c8c32016-09-06 14:04:48 +0100889}
890
891TEST_F(VerifierDepsTest, InvokeDirect_Resolved_DeclaredInReferenced) {
892 ASSERT_TRUE(VerifyMethod("InvokeDirect_Resolved_DeclaredInReferenced"));
893 ASSERT_TRUE(HasClass("Ljava/net/Socket;", true, "public"));
Vladimir Markoba118822017-06-12 15:41:56 +0100894 ASSERT_TRUE(HasMethod("Ljava/net/Socket;",
895 "<init>",
896 "()V",
897 /* expect_resolved */ true,
898 "public",
899 "Ljava/net/Socket;"));
David Brazdilca3c8c32016-09-06 14:04:48 +0100900}
901
902TEST_F(VerifierDepsTest, InvokeDirect_Resolved_DeclaredInSuperclass1) {
903 ASSERT_FALSE(VerifyMethod("InvokeDirect_Resolved_DeclaredInSuperclass1"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000904 ASSERT_TRUE(HasClass("Ljavax/net/ssl/SSLSocket;", true, "public"));
Vladimir Markoba118822017-06-12 15:41:56 +0100905 ASSERT_TRUE(HasMethod("Ljavax/net/ssl/SSLSocket;",
David Brazdilca3c8c32016-09-06 14:04:48 +0100906 "checkOldImpl",
907 "()V",
Vladimir Markoba118822017-06-12 15:41:56 +0100908 /* expect_resolved */ true,
David Brazdilca3c8c32016-09-06 14:04:48 +0100909 "private",
910 "Ljava/net/Socket;"));
911}
912
913TEST_F(VerifierDepsTest, InvokeDirect_Resolved_DeclaredInSuperclass2) {
914 ASSERT_FALSE(VerifyMethod("InvokeDirect_Resolved_DeclaredInSuperclass2"));
Vladimir Markoba118822017-06-12 15:41:56 +0100915 ASSERT_TRUE(HasMethod("LMySSLSocket;",
916 "checkOldImpl",
917 "()V",
918 /* expect_resolved */ true,
919 "private",
920 "Ljava/net/Socket;"));
David Brazdilca3c8c32016-09-06 14:04:48 +0100921}
922
923TEST_F(VerifierDepsTest, InvokeDirect_Unresolved1) {
924 ASSERT_FALSE(VerifyMethod("InvokeDirect_Unresolved1"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000925 ASSERT_TRUE(HasClass("Ljavax/net/ssl/SSLSocket;", true, "public"));
Vladimir Markoba118822017-06-12 15:41:56 +0100926 ASSERT_TRUE(HasMethod("Ljavax/net/ssl/SSLSocket;",
927 "x",
928 "()V",
929 /* expect_resolved */ false));
David Brazdilca3c8c32016-09-06 14:04:48 +0100930}
931
932TEST_F(VerifierDepsTest, InvokeDirect_Unresolved2) {
933 ASSERT_FALSE(VerifyMethod("InvokeDirect_Unresolved2"));
Vladimir Markoba118822017-06-12 15:41:56 +0100934 ASSERT_TRUE(HasMethod("LMySSLSocket;",
935 "x",
936 "()V",
937 /* expect_resolved */ false));
David Brazdilca3c8c32016-09-06 14:04:48 +0100938}
939
940TEST_F(VerifierDepsTest, InvokeVirtual_Resolved_DeclaredInReferenced) {
941 ASSERT_TRUE(VerifyMethod("InvokeVirtual_Resolved_DeclaredInReferenced"));
942 ASSERT_TRUE(HasClass("Ljava/lang/Throwable;", true, "public"));
Vladimir Markoba118822017-06-12 15:41:56 +0100943 ASSERT_TRUE(HasMethod("Ljava/lang/Throwable;",
David Brazdilca3c8c32016-09-06 14:04:48 +0100944 "getMessage",
945 "()Ljava/lang/String;",
Vladimir Markoba118822017-06-12 15:41:56 +0100946 /* expect_resolved */ true,
David Brazdilca3c8c32016-09-06 14:04:48 +0100947 "public",
948 "Ljava/lang/Throwable;"));
949 // Type dependency on `this` argument.
Nicolas Geoffray119e8462016-12-21 10:29:43 +0000950 ASSERT_TRUE(HasAssignable("Ljava/lang/Throwable;", "Ljava/net/SocketTimeoutException;", true));
David Brazdilca3c8c32016-09-06 14:04:48 +0100951}
952
953TEST_F(VerifierDepsTest, InvokeVirtual_Resolved_DeclaredInSuperclass1) {
954 ASSERT_TRUE(VerifyMethod("InvokeVirtual_Resolved_DeclaredInSuperclass1"));
955 ASSERT_TRUE(HasClass("Ljava/io/InterruptedIOException;", true, "public"));
Vladimir Markoba118822017-06-12 15:41:56 +0100956 ASSERT_TRUE(HasMethod("Ljava/io/InterruptedIOException;",
David Brazdilca3c8c32016-09-06 14:04:48 +0100957 "getMessage",
958 "()Ljava/lang/String;",
Vladimir Markoba118822017-06-12 15:41:56 +0100959 /* expect_resolved */ true,
David Brazdilca3c8c32016-09-06 14:04:48 +0100960 "public",
961 "Ljava/lang/Throwable;"));
962 // Type dependency on `this` argument.
Nicolas Geoffray119e8462016-12-21 10:29:43 +0000963 ASSERT_TRUE(HasAssignable("Ljava/lang/Throwable;", "Ljava/net/SocketTimeoutException;", true));
David Brazdilca3c8c32016-09-06 14:04:48 +0100964}
965
966TEST_F(VerifierDepsTest, InvokeVirtual_Resolved_DeclaredInSuperclass2) {
967 ASSERT_TRUE(VerifyMethod("InvokeVirtual_Resolved_DeclaredInSuperclass2"));
Vladimir Markoba118822017-06-12 15:41:56 +0100968 ASSERT_TRUE(HasMethod("LMySocketTimeoutException;",
David Brazdilca3c8c32016-09-06 14:04:48 +0100969 "getMessage",
970 "()Ljava/lang/String;",
Vladimir Markoba118822017-06-12 15:41:56 +0100971 /* expect_resolved */ true,
David Brazdilca3c8c32016-09-06 14:04:48 +0100972 "public",
973 "Ljava/lang/Throwable;"));
974}
975
976TEST_F(VerifierDepsTest, InvokeVirtual_Resolved_DeclaredInSuperinterface) {
977 ASSERT_TRUE(VerifyMethod("InvokeVirtual_Resolved_DeclaredInSuperinterface"));
Vladimir Markoba118822017-06-12 15:41:56 +0100978 ASSERT_TRUE(HasMethod("LMyThreadSet;",
David Brazdilca3c8c32016-09-06 14:04:48 +0100979 "size",
980 "()I",
Vladimir Markoba118822017-06-12 15:41:56 +0100981 /* expect_resolved */ true,
Nicolas Geoffray6e54f782017-03-08 15:27:09 +0000982 "public",
David Brazdilca3c8c32016-09-06 14:04:48 +0100983 "Ljava/util/Set;"));
984}
985
986TEST_F(VerifierDepsTest, InvokeVirtual_Unresolved1) {
987 ASSERT_FALSE(VerifyMethod("InvokeVirtual_Unresolved1"));
988 ASSERT_TRUE(HasClass("Ljava/io/InterruptedIOException;", true, "public"));
Vladimir Markoba118822017-06-12 15:41:56 +0100989 ASSERT_TRUE(HasMethod("Ljava/io/InterruptedIOException;",
990 "x",
991 "()V",
992 /* expect_resolved */ false));
David Brazdilca3c8c32016-09-06 14:04:48 +0100993}
994
995TEST_F(VerifierDepsTest, InvokeVirtual_Unresolved2) {
996 ASSERT_FALSE(VerifyMethod("InvokeVirtual_Unresolved2"));
Vladimir Markoba118822017-06-12 15:41:56 +0100997 ASSERT_TRUE(HasMethod("LMySocketTimeoutException;",
998 "x",
999 "()V",
1000 /* expect_resolved */ false));
David Brazdilca3c8c32016-09-06 14:04:48 +01001001}
1002
1003TEST_F(VerifierDepsTest, InvokeInterface_Resolved_DeclaredInReferenced) {
1004 ASSERT_TRUE(VerifyMethod("InvokeInterface_Resolved_DeclaredInReferenced"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +00001005 ASSERT_TRUE(HasClass("Ljava/lang/Runnable;", true, "public interface"));
Vladimir Markoba118822017-06-12 15:41:56 +01001006 ASSERT_TRUE(HasMethod("Ljava/lang/Runnable;",
David Brazdilca3c8c32016-09-06 14:04:48 +01001007 "run",
1008 "()V",
Vladimir Markoba118822017-06-12 15:41:56 +01001009 /* expect_resolved */ true,
Nicolas Geoffray6e54f782017-03-08 15:27:09 +00001010 "public",
David Brazdilca3c8c32016-09-06 14:04:48 +01001011 "Ljava/lang/Runnable;"));
1012}
1013
1014TEST_F(VerifierDepsTest, InvokeInterface_Resolved_DeclaredInSuperclass) {
1015 ASSERT_FALSE(VerifyMethod("InvokeInterface_Resolved_DeclaredInSuperclass"));
Vladimir Markoba118822017-06-12 15:41:56 +01001016 // TODO: Maybe we should not record dependency if the invoke type does not match the lookup type.
1017 ASSERT_TRUE(HasMethod("LMyThread;",
1018 "join",
1019 "()V",
1020 /* expect_resolved */ true,
1021 "public",
1022 "Ljava/lang/Thread;"));
David Brazdilca3c8c32016-09-06 14:04:48 +01001023}
1024
1025TEST_F(VerifierDepsTest, InvokeInterface_Resolved_DeclaredInSuperinterface1) {
1026 ASSERT_FALSE(VerifyMethod("InvokeInterface_Resolved_DeclaredInSuperinterface1"));
Vladimir Markoba118822017-06-12 15:41:56 +01001027 // TODO: Maybe we should not record dependency if the invoke type does not match the lookup type.
1028 ASSERT_TRUE(HasMethod("LMyThreadSet;",
David Brazdilca3c8c32016-09-06 14:04:48 +01001029 "run",
1030 "()V",
Vladimir Markoba118822017-06-12 15:41:56 +01001031 /* expect_resolved */ true,
Nicolas Geoffray6e54f782017-03-08 15:27:09 +00001032 "public",
Vladimir Markoba118822017-06-12 15:41:56 +01001033 "Ljava/lang/Thread;"));
David Brazdilca3c8c32016-09-06 14:04:48 +01001034}
1035
1036TEST_F(VerifierDepsTest, InvokeInterface_Resolved_DeclaredInSuperinterface2) {
1037 ASSERT_FALSE(VerifyMethod("InvokeInterface_Resolved_DeclaredInSuperinterface2"));
Vladimir Markoba118822017-06-12 15:41:56 +01001038 ASSERT_TRUE(HasMethod("LMyThreadSet;",
David Brazdilca3c8c32016-09-06 14:04:48 +01001039 "isEmpty",
1040 "()Z",
Vladimir Markoba118822017-06-12 15:41:56 +01001041 /* expect_resolved */ true,
Nicolas Geoffray6e54f782017-03-08 15:27:09 +00001042 "public",
David Brazdilca3c8c32016-09-06 14:04:48 +01001043 "Ljava/util/Set;"));
1044}
1045
1046TEST_F(VerifierDepsTest, InvokeInterface_Unresolved1) {
1047 ASSERT_FALSE(VerifyMethod("InvokeInterface_Unresolved1"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +00001048 ASSERT_TRUE(HasClass("Ljava/lang/Runnable;", true, "public interface"));
Vladimir Markoba118822017-06-12 15:41:56 +01001049 ASSERT_TRUE(HasMethod("Ljava/lang/Runnable;",
1050 "x",
1051 "()V",
1052 /* expect_resolved */ false));
David Brazdilca3c8c32016-09-06 14:04:48 +01001053}
1054
1055TEST_F(VerifierDepsTest, InvokeInterface_Unresolved2) {
1056 ASSERT_FALSE(VerifyMethod("InvokeInterface_Unresolved2"));
Vladimir Markoba118822017-06-12 15:41:56 +01001057 ASSERT_TRUE(HasMethod("LMyThreadSet;", "x", "()V", /* expect_resolved */ false));
David Brazdilca3c8c32016-09-06 14:04:48 +01001058}
1059
1060TEST_F(VerifierDepsTest, InvokeSuper_ThisAssignable) {
1061 ASSERT_TRUE(VerifyMethod("InvokeSuper_ThisAssignable"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +00001062 ASSERT_TRUE(HasClass("Ljava/lang/Runnable;", true, "public interface"));
Nicolas Geoffray0e2fe0f2016-12-21 16:54:52 +00001063 ASSERT_TRUE(HasAssignable("Ljava/lang/Runnable;", "Ljava/lang/Thread;", true));
Vladimir Markoba118822017-06-12 15:41:56 +01001064 ASSERT_TRUE(HasMethod("Ljava/lang/Runnable;",
David Brazdilca3c8c32016-09-06 14:04:48 +01001065 "run",
1066 "()V",
Vladimir Markoba118822017-06-12 15:41:56 +01001067 /* expect_resolved */ true,
Nicolas Geoffray6e54f782017-03-08 15:27:09 +00001068 "public",
David Brazdilca3c8c32016-09-06 14:04:48 +01001069 "Ljava/lang/Runnable;"));
1070}
1071
1072TEST_F(VerifierDepsTest, InvokeSuper_ThisNotAssignable) {
1073 ASSERT_FALSE(VerifyMethod("InvokeSuper_ThisNotAssignable"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +00001074 ASSERT_TRUE(HasClass("Ljava/lang/Integer;", true, "public"));
Nicolas Geoffray119e8462016-12-21 10:29:43 +00001075 ASSERT_TRUE(HasAssignable("Ljava/lang/Integer;", "Ljava/lang/Thread;", false));
Vladimir Markoba118822017-06-12 15:41:56 +01001076 ASSERT_TRUE(HasMethod("Ljava/lang/Integer;",
1077 "intValue", "()I",
1078 /* expect_resolved */ true,
1079 "public", "Ljava/lang/Integer;"));
David Brazdilca3c8c32016-09-06 14:04:48 +01001080}
1081
Nicolas Geoffray0f1cb172017-01-05 15:23:19 +00001082TEST_F(VerifierDepsTest, ArgumentType_ResolvedReferenceArray) {
1083 ASSERT_TRUE(VerifyMethod("ArgumentType_ResolvedReferenceArray"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +00001084 ASSERT_TRUE(HasClass("[Ljava/lang/Thread;", true, "public"));
Nicolas Geoffray0f1cb172017-01-05 15:23:19 +00001085}
1086
1087TEST_F(VerifierDepsTest, NewArray_Resolved) {
1088 ASSERT_TRUE(VerifyMethod("NewArray_Resolved"));
Nicolas Geoffray6e54f782017-03-08 15:27:09 +00001089 ASSERT_TRUE(HasClass("[Ljava/lang/IllegalStateException;", true, "public"));
Nicolas Geoffray0f1cb172017-01-05 15:23:19 +00001090}
1091
David Brazdil6f82fbd2016-09-14 11:55:26 +01001092TEST_F(VerifierDepsTest, EncodeDecode) {
1093 VerifyDexFile();
1094
1095 ASSERT_EQ(1u, NumberOfCompiledDexFiles());
1096 ASSERT_TRUE(HasEachKindOfRecord());
1097
1098 std::vector<uint8_t> buffer;
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +01001099 verifier_deps_->Encode(dex_files_, &buffer);
David Brazdil6f82fbd2016-09-14 11:55:26 +01001100 ASSERT_FALSE(buffer.empty());
1101
Nicolas Geoffraye70dd562016-10-30 21:03:35 +00001102 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
David Brazdil6f82fbd2016-09-14 11:55:26 +01001103 ASSERT_TRUE(verifier_deps_->Equals(decoded_deps));
1104}
1105
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +01001106TEST_F(VerifierDepsTest, EncodeDecodeMulti) {
1107 VerifyDexFile("MultiDex");
1108
1109 ASSERT_GT(NumberOfCompiledDexFiles(), 1u);
1110 std::vector<uint8_t> buffer;
1111 verifier_deps_->Encode(dex_files_, &buffer);
1112 ASSERT_FALSE(buffer.empty());
1113
1114 // Create new DexFile, to mess with std::map order: the verifier deps used
1115 // to iterate over the map, which doesn't guarantee insertion order. We fixed
1116 // this by passing the expected order when encoding/decoding.
1117 std::vector<std::unique_ptr<const DexFile>> first_dex_files = OpenTestDexFiles("VerifierDeps");
1118 std::vector<std::unique_ptr<const DexFile>> second_dex_files = OpenTestDexFiles("MultiDex");
1119 std::vector<const DexFile*> dex_files;
1120 for (auto& dex_file : first_dex_files) {
1121 dex_files.push_back(dex_file.get());
1122 }
1123 for (auto& dex_file : second_dex_files) {
1124 dex_files.push_back(dex_file.get());
1125 }
1126
1127 // Dump the new verifier deps to ensure it can properly read the data.
Nicolas Geoffraye70dd562016-10-30 21:03:35 +00001128 VerifierDeps decoded_deps(dex_files, ArrayRef<const uint8_t>(buffer));
Nicolas Geoffrayd01f60c2016-10-28 14:45:48 +01001129 std::ostringstream stream;
1130 VariableIndentationOutputStream os(&stream);
1131 decoded_deps.Dump(&os);
1132}
1133
Nicolas Geoffray08025182016-10-25 17:20:18 +01001134TEST_F(VerifierDepsTest, UnverifiedClasses) {
1135 VerifyDexFile();
1136 ASSERT_FALSE(HasUnverifiedClass("LMyThread;"));
1137 // Test that a class with a soft failure is recorded.
1138 ASSERT_TRUE(HasUnverifiedClass("LMain;"));
1139 // Test that a class with hard failure is recorded.
1140 ASSERT_TRUE(HasUnverifiedClass("LMyVerificationFailure;"));
1141 // Test that a class with unresolved super is recorded.
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +00001142 ASSERT_TRUE(HasUnverifiedClass("LMyClassWithNoSuper;"));
Nicolas Geoffray08025182016-10-25 17:20:18 +01001143 // Test that a class with unresolved super and hard failure is recorded.
1144 ASSERT_TRUE(HasUnverifiedClass("LMyClassWithNoSuperButFailures;"));
1145}
1146
Mathieu Chartierbf755fe2017-08-01 13:42:56 -07001147TEST_F(VerifierDepsTest, UnverifiedOrder) {
1148 ScopedObjectAccess soa(Thread::Current());
1149 jobject loader = LoadDex("VerifierDeps");
1150 std::vector<const DexFile*> dex_files = GetDexFiles(loader);
1151 ASSERT_GT(dex_files.size(), 0u);
1152 const DexFile* dex_file = dex_files[0];
1153 VerifierDeps deps1(dex_files);
1154 Thread* const self = Thread::Current();
1155 ASSERT_TRUE(self->GetVerifierDeps() == nullptr);
1156 self->SetVerifierDeps(&deps1);
1157 deps1.MaybeRecordVerificationStatus(*dex_file,
1158 dex::TypeIndex(0),
1159 verifier::FailureKind::kHardFailure);
1160 deps1.MaybeRecordVerificationStatus(*dex_file,
1161 dex::TypeIndex(1),
1162 verifier::FailureKind::kHardFailure);
1163 VerifierDeps deps2(dex_files);
1164 self->SetVerifierDeps(nullptr);
1165 self->SetVerifierDeps(&deps2);
1166 deps2.MaybeRecordVerificationStatus(*dex_file,
1167 dex::TypeIndex(1),
1168 verifier::FailureKind::kHardFailure);
1169 deps2.MaybeRecordVerificationStatus(*dex_file,
1170 dex::TypeIndex(0),
1171 verifier::FailureKind::kHardFailure);
1172 self->SetVerifierDeps(nullptr);
1173 std::vector<uint8_t> buffer1;
1174 deps1.Encode(dex_files, &buffer1);
1175 std::vector<uint8_t> buffer2;
1176 deps2.Encode(dex_files, &buffer2);
1177 EXPECT_EQ(buffer1, buffer2);
1178}
1179
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001180TEST_F(VerifierDepsTest, VerifyDeps) {
1181 VerifyDexFile();
1182
1183 ASSERT_EQ(1u, NumberOfCompiledDexFiles());
1184 ASSERT_TRUE(HasEachKindOfRecord());
1185
1186 // When validating, we create a new class loader, as
1187 // the existing `class_loader_` may contain erroneous classes,
1188 // that ClassLinker::FindClass won't return.
1189
1190 ScopedObjectAccess soa(Thread::Current());
1191 StackHandleScope<1> hs(soa.Self());
1192 MutableHandle<mirror::ClassLoader> new_class_loader(hs.NewHandle<mirror::ClassLoader>(nullptr));
1193 {
1194 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001195 ASSERT_TRUE(verifier_deps_->ValidateDependencies(new_class_loader, soa.Self()));
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001196 }
1197
1198 std::vector<uint8_t> buffer;
1199 verifier_deps_->Encode(dex_files_, &buffer);
1200 ASSERT_FALSE(buffer.empty());
1201
1202 {
1203 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1204 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001205 ASSERT_TRUE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001206 }
1207
1208 // Fiddle with the dependencies to make sure we catch any change and fail to verify.
1209
1210 {
1211 // Mess up with the assignable_types.
1212 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1213 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1214 deps->assignable_types_.insert(*deps->unassignable_types_.begin());
1215 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001216 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001217 }
1218
1219 {
1220 // Mess up with the unassignable_types.
1221 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1222 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1223 deps->unassignable_types_.insert(*deps->assignable_types_.begin());
1224 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001225 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001226 }
1227
1228 // Mess up with classes.
1229 {
1230 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1231 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1232 bool found = false;
1233 for (const auto& entry : deps->classes_) {
1234 if (entry.IsResolved()) {
1235 deps->classes_.insert(VerifierDeps::ClassResolution(
1236 entry.GetDexTypeIndex(), VerifierDeps::kUnresolvedMarker));
1237 found = true;
1238 break;
1239 }
1240 }
1241 ASSERT_TRUE(found);
1242 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001243 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001244 }
1245
1246 {
1247 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1248 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1249 bool found = false;
1250 for (const auto& entry : deps->classes_) {
1251 if (!entry.IsResolved()) {
1252 deps->classes_.insert(VerifierDeps::ClassResolution(
1253 entry.GetDexTypeIndex(), VerifierDeps::kUnresolvedMarker - 1));
1254 found = true;
1255 break;
1256 }
1257 }
1258 ASSERT_TRUE(found);
1259 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001260 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001261 }
1262
1263 {
1264 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1265 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1266 bool found = false;
1267 for (const auto& entry : deps->classes_) {
1268 if (entry.IsResolved()) {
1269 deps->classes_.insert(VerifierDeps::ClassResolution(
1270 entry.GetDexTypeIndex(), entry.GetAccessFlags() - 1));
1271 found = true;
1272 break;
1273 }
1274 }
1275 ASSERT_TRUE(found);
1276 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001277 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001278 }
1279
1280 // Mess up with fields.
1281 {
1282 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1283 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1284 bool found = false;
1285 for (const auto& entry : deps->fields_) {
1286 if (entry.IsResolved()) {
1287 deps->fields_.insert(VerifierDeps::FieldResolution(entry.GetDexFieldIndex(),
1288 VerifierDeps::kUnresolvedMarker,
1289 entry.GetDeclaringClassIndex()));
1290 found = true;
1291 break;
1292 }
1293 }
1294 ASSERT_TRUE(found);
1295 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001296 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001297 }
1298
1299 {
1300 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1301 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1302 bool found = false;
1303 for (const auto& entry : deps->fields_) {
1304 if (!entry.IsResolved()) {
Andreas Gampe8a0128a2016-11-28 07:38:35 -08001305 constexpr dex::StringIndex kStringIndexZero(0); // We know there is a class there.
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001306 deps->fields_.insert(VerifierDeps::FieldResolution(0 /* we know there is a field there */,
1307 VerifierDeps::kUnresolvedMarker - 1,
Andreas Gampe8a0128a2016-11-28 07:38:35 -08001308 kStringIndexZero));
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001309 found = true;
1310 break;
1311 }
1312 }
1313 ASSERT_TRUE(found);
1314 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001315 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001316 }
1317
1318 {
1319 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1320 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1321 bool found = false;
1322 for (const auto& entry : deps->fields_) {
1323 if (entry.IsResolved()) {
1324 deps->fields_.insert(VerifierDeps::FieldResolution(entry.GetDexFieldIndex(),
1325 entry.GetAccessFlags() - 1,
1326 entry.GetDeclaringClassIndex()));
1327 found = true;
1328 break;
1329 }
1330 }
1331 ASSERT_TRUE(found);
1332 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001333 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001334 }
1335
1336 {
1337 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1338 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1339 bool found = false;
1340 for (const auto& entry : deps->fields_) {
Andreas Gampe8a0128a2016-11-28 07:38:35 -08001341 constexpr dex::StringIndex kNewTypeIndex(0);
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001342 if (entry.GetDeclaringClassIndex() != kNewTypeIndex) {
1343 deps->fields_.insert(VerifierDeps::FieldResolution(entry.GetDexFieldIndex(),
1344 entry.GetAccessFlags(),
1345 kNewTypeIndex));
1346 found = true;
1347 break;
1348 }
1349 }
1350 ASSERT_TRUE(found);
1351 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001352 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001353 }
1354
1355 // Mess up with methods.
Vladimir Markoba118822017-06-12 15:41:56 +01001356 {
1357 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1358 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1359 bool found = false;
1360 std::set<VerifierDeps::MethodResolution>* methods = &deps->methods_;
1361 for (const auto& entry : *methods) {
1362 if (entry.IsResolved()) {
1363 methods->insert(VerifierDeps::MethodResolution(entry.GetDexMethodIndex(),
1364 VerifierDeps::kUnresolvedMarker,
1365 entry.GetDeclaringClassIndex()));
1366 found = true;
1367 break;
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001368 }
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001369 }
Vladimir Markoba118822017-06-12 15:41:56 +01001370 ASSERT_TRUE(found);
1371 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
1372 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
1373 }
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001374
Vladimir Markoba118822017-06-12 15:41:56 +01001375 {
1376 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1377 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1378 bool found = false;
1379 std::set<VerifierDeps::MethodResolution>* methods = &deps->methods_;
1380 for (const auto& entry : *methods) {
1381 if (!entry.IsResolved()) {
1382 constexpr dex::StringIndex kStringIndexZero(0); // We know there is a class there.
1383 methods->insert(VerifierDeps::MethodResolution(0 /* we know there is a method there */,
1384 VerifierDeps::kUnresolvedMarker - 1,
1385 kStringIndexZero));
1386 found = true;
1387 break;
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001388 }
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001389 }
Vladimir Markoba118822017-06-12 15:41:56 +01001390 ASSERT_TRUE(found);
1391 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
1392 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
1393 }
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001394
Vladimir Markoba118822017-06-12 15:41:56 +01001395 {
1396 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1397 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1398 bool found = false;
1399 std::set<VerifierDeps::MethodResolution>* methods = &deps->methods_;
1400 for (const auto& entry : *methods) {
1401 if (entry.IsResolved()) {
1402 methods->insert(VerifierDeps::MethodResolution(entry.GetDexMethodIndex(),
1403 entry.GetAccessFlags() - 1,
1404 entry.GetDeclaringClassIndex()));
1405 found = true;
1406 break;
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001407 }
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001408 }
Vladimir Markoba118822017-06-12 15:41:56 +01001409 ASSERT_TRUE(found);
1410 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
1411 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
1412 }
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001413
Vladimir Markoba118822017-06-12 15:41:56 +01001414 {
1415 VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1416 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1417 bool found = false;
1418 std::set<VerifierDeps::MethodResolution>* methods = &deps->methods_;
1419 for (const auto& entry : *methods) {
1420 constexpr dex::StringIndex kNewTypeIndex(0);
1421 if (entry.IsResolved() && entry.GetDeclaringClassIndex() != kNewTypeIndex) {
1422 methods->insert(VerifierDeps::MethodResolution(entry.GetDexMethodIndex(),
1423 entry.GetAccessFlags(),
1424 kNewTypeIndex));
1425 found = true;
1426 break;
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001427 }
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001428 }
Vladimir Markoba118822017-06-12 15:41:56 +01001429 ASSERT_TRUE(found);
1430 new_class_loader.Assign(soa.Decode<mirror::ClassLoader>(LoadDex("VerifierDeps")));
1431 ASSERT_FALSE(decoded_deps.ValidateDependencies(new_class_loader, soa.Self()));
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001432 }
1433}
1434
1435TEST_F(VerifierDepsTest, CompilerDriver) {
1436 SetupCompilerDriver();
1437
1438 // Test both multi-dex and single-dex configuration.
1439 for (const char* multi : { "MultiDex", static_cast<const char*>(nullptr) }) {
1440 // Test that the compiler driver behaves as expected when the dependencies
1441 // verify and when they don't verify.
1442 for (bool verify_failure : { false, true }) {
1443 {
1444 ScopedObjectAccess soa(Thread::Current());
1445 LoadDexFile(&soa, "VerifierDeps", multi);
1446 }
1447 VerifyWithCompilerDriver(/* verifier_deps */ nullptr);
1448
1449 std::vector<uint8_t> buffer;
1450 verifier_deps_->Encode(dex_files_, &buffer);
1451
1452 {
1453 ScopedObjectAccess soa(Thread::Current());
1454 LoadDexFile(&soa, "VerifierDeps", multi);
1455 }
1456 verifier::VerifierDeps decoded_deps(dex_files_, ArrayRef<const uint8_t>(buffer));
1457 if (verify_failure) {
1458 // Just taint the decoded VerifierDeps with one invalid entry.
1459 VerifierDeps::DexFileDeps* deps = decoded_deps.GetDexFileDeps(*primary_dex_file_);
1460 bool found = false;
1461 for (const auto& entry : deps->classes_) {
1462 if (entry.IsResolved()) {
1463 deps->classes_.insert(VerifierDeps::ClassResolution(
1464 entry.GetDexTypeIndex(), VerifierDeps::kUnresolvedMarker));
1465 found = true;
1466 break;
1467 }
1468 }
1469 ASSERT_TRUE(found);
1470 }
1471 VerifyWithCompilerDriver(&decoded_deps);
1472
1473 if (verify_failure) {
1474 ASSERT_FALSE(verifier_deps_ == nullptr);
1475 ASSERT_FALSE(verifier_deps_->Equals(decoded_deps));
1476 } else {
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +00001477 VerifyClassStatus(decoded_deps);
1478 }
Nicolas Geoffray8904b6f2016-10-28 19:50:34 +01001479 }
1480 }
1481}
1482
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +00001483TEST_F(VerifierDepsTest, MultiDexVerification) {
1484 VerifyDexFile("VerifierDepsMulti");
1485 ASSERT_EQ(NumberOfCompiledDexFiles(), 2u);
1486
1487 ASSERT_TRUE(HasUnverifiedClass("LMySoftVerificationFailure;", *dex_files_[1]));
1488 ASSERT_TRUE(HasUnverifiedClass("LMySub1SoftVerificationFailure;", *dex_files_[0]));
1489 ASSERT_TRUE(HasUnverifiedClass("LMySub2SoftVerificationFailure;", *dex_files_[0]));
1490
1491 std::vector<uint8_t> buffer;
1492 verifier_deps_->Encode(dex_files_, &buffer);
1493 ASSERT_FALSE(buffer.empty());
1494}
1495
Nicolas Geoffrayfc38e912017-03-16 16:51:59 +00001496TEST_F(VerifierDepsTest, NotAssignable_InterfaceWithClassInBoot) {
1497 ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "Ljava/lang/Exception;",
1498 /* src */ "LIface;",
1499 /* is_strict */ true,
1500 /* is_assignable */ false));
1501 ASSERT_TRUE(HasAssignable("Ljava/lang/Exception;", "LIface;", false));
1502}
1503
Nicolas Geoffraybdb540d2017-04-19 13:50:34 +01001504TEST_F(VerifierDepsTest, Assignable_Arrays) {
1505 ASSERT_TRUE(TestAssignabilityRecording(/* dst */ "[LIface;",
1506 /* src */ "[LMyClassExtendingInterface;",
1507 /* is_strict */ false,
1508 /* is_assignable */ true));
1509 ASSERT_FALSE(HasAssignable(
1510 "LIface;", "LMyClassExtendingInterface;", /* expected_is_assignable */ true));
1511 ASSERT_FALSE(HasAssignable(
1512 "LIface;", "LMyClassExtendingInterface;", /* expected_is_assignable */ false));
1513}
1514
David Brazdilca3c8c32016-09-06 14:04:48 +01001515} // namespace verifier
1516} // namespace art