@@ -51,6 +51,13 @@ object Logger {
5151 System .out .flush()
5252 }
5353
54+
55+ private val sparseArrayCompatAvailable = try {
56+ SparseArrayCompat ::class .qualifiedName != null
57+ } catch (e: NoClassDefFoundError ) {
58+ false
59+ }
60+
5461 private fun Any?.dump (name : String , indent : Int , processed : MutableSet <Any >, forceInclude : Set <Any >, forceIncludeClasses : Set <Class <* >>) {
5562 // <editor-fold defaultstate="collapsed" desc="...">
5663
@@ -108,7 +115,7 @@ object Logger {
108115 }
109116 }
110117 }
111- this is SparseLongArray -> {
118+ Build . VERSION . SDK_INT >= 18 && this is SparseLongArray -> {
112119 if (this .isEmpty()) {
113120 println (" []" )
114121 } else {
@@ -128,7 +135,7 @@ object Logger {
128135 }
129136 }
130137 }
131- this is SparseArrayCompat <* > -> {
138+ sparseArrayCompatAvailable && this is SparseArrayCompat <* > -> {
132139 if (this .size() == 0 ) {
133140 println (" []" )
134141 } else {
@@ -225,17 +232,21 @@ object Logger {
225232 it.isAccessible = true
226233 try {
227234 it.get(this ).dump(it.name, nextIndent, processed, forceInclude, forceIncludeClasses)
228- } catch (e: ReflectiveOperationException ) {
229- e.printStackTrace()
235+ } catch (e: Exception ) {
236+ val cause = e.cause
237+ if (cause != null ) cause.printStackTrace()
238+ else e.printStackTrace()
230239 }
231240 }
232241
233242 methods.sortedBy { it.name }.forEach {
234243 it.isAccessible = true
235244 try {
236245 it.invoke(this ).dump(it.name, nextIndent, processed, forceInclude, forceIncludeClasses)
237- } catch (e: ReflectiveOperationException ) {
238- e.printStackTrace()
246+ } catch (e: Exception ) {
247+ val cause = e.cause
248+ if (cause != null ) cause.printStackTrace()
249+ else e.printStackTrace()
239250 }
240251 }
241252 }
0 commit comments