1 /*
2  * Copyright (C) 2019 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 #include "reflective_value_visitor.h"
18 #include <sstream>
19 
20 #include "base/locks.h"
21 #include "base/mutex-inl.h"
22 #include "mirror/class.h"
23 #include "mirror/object-inl.h"
24 
25 namespace art {
26 
Describe(std::ostream & os) const27 void HeapReflectiveSourceInfo::Describe(std::ostream& os) const {
28   Locks::mutator_lock_->AssertExclusiveHeld(Thread::Current());
29   ReflectionSourceInfo::Describe(os);
30   os << " Class=" << src_->GetClass()->PrettyClass();
31 }
32 
33 template<>
Describe(std::ostream & os) const34 void JniIdReflectiveSourceInfo<jfieldID>::Describe(std::ostream& os) const {
35   ReflectionSourceInfo::Describe(os);
36   os << " jfieldID=" << reinterpret_cast<uintptr_t>(id_);
37 }
38 
39 template<>
Describe(std::ostream & os) const40 void JniIdReflectiveSourceInfo<jmethodID>::Describe(std::ostream& os) const {
41   ReflectionSourceInfo::Describe(os);
42   os << " jmethodID=" << reinterpret_cast<uintptr_t>(id_);
43 }
44 
Describe(std::ostream & os) const45 void ReflectiveHandleScopeSourceInfo::Describe(std::ostream& os) const {
46   ReflectionSourceInfo::Describe(os);
47   os << " source= (" << source_ << ") ";
48   if (source_ == nullptr) {
49     os << "nullptr";
50   } else {
51     os << *source_;
52   }
53 }
54 }  // namespace art
55