OptionalMethod.smali 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. .class Lokhttp3/internal/platform/OptionalMethod;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/Signature;
  6. value = {
  7. "<T:",
  8. "Ljava/lang/Object;",
  9. ">",
  10. "Ljava/lang/Object;"
  11. }
  12. .end annotation
  13. # instance fields
  14. .field private final methodName:Ljava/lang/String;
  15. .field private final methodParams:[Ljava/lang/Class;
  16. .field private final returnType:Ljava/lang/Class;
  17. .annotation system Ldalvik/annotation/Signature;
  18. value = {
  19. "Ljava/lang/Class<",
  20. "*>;"
  21. }
  22. .end annotation
  23. .end field
  24. # direct methods
  25. .method varargs constructor <init>(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)V
  26. .locals 0
  27. .annotation system Ldalvik/annotation/Signature;
  28. value = {
  29. "(",
  30. "Ljava/lang/Class<",
  31. "*>;",
  32. "Ljava/lang/String;",
  33. "[",
  34. "Ljava/lang/Class;",
  35. ")V"
  36. }
  37. .end annotation
  38. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  39. iput-object p1, p0, Lokhttp3/internal/platform/OptionalMethod;->returnType:Ljava/lang/Class;
  40. iput-object p2, p0, Lokhttp3/internal/platform/OptionalMethod;->methodName:Ljava/lang/String;
  41. iput-object p3, p0, Lokhttp3/internal/platform/OptionalMethod;->methodParams:[Ljava/lang/Class;
  42. return-void
  43. .end method
  44. .method private getMethod(Ljava/lang/Class;)Ljava/lang/reflect/Method;
  45. .locals 3
  46. .annotation system Ldalvik/annotation/Signature;
  47. value = {
  48. "(",
  49. "Ljava/lang/Class<",
  50. "*>;)",
  51. "Ljava/lang/reflect/Method;"
  52. }
  53. .end annotation
  54. iget-object v0, p0, Lokhttp3/internal/platform/OptionalMethod;->methodName:Ljava/lang/String;
  55. const/4 v1, 0x0
  56. if-eqz v0, :cond_1
  57. iget-object v2, p0, Lokhttp3/internal/platform/OptionalMethod;->methodParams:[Ljava/lang/Class;
  58. invoke-static {p1, v0, v2}, Lokhttp3/internal/platform/OptionalMethod;->getPublicMethod(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
  59. move-result-object p1
  60. if-eqz p1, :cond_0
  61. iget-object v0, p0, Lokhttp3/internal/platform/OptionalMethod;->returnType:Ljava/lang/Class;
  62. if-eqz v0, :cond_0
  63. invoke-virtual {p1}, Ljava/lang/reflect/Method;->getReturnType()Ljava/lang/Class;
  64. move-result-object v2
  65. invoke-virtual {v0, v2}, Ljava/lang/Class;->isAssignableFrom(Ljava/lang/Class;)Z
  66. move-result v0
  67. if-nez v0, :cond_0
  68. goto :goto_0
  69. :cond_0
  70. move-object v1, p1
  71. :cond_1
  72. :goto_0
  73. return-object v1
  74. .end method
  75. .method private static getPublicMethod(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
  76. .locals 1
  77. .annotation system Ldalvik/annotation/Signature;
  78. value = {
  79. "(",
  80. "Ljava/lang/Class<",
  81. "*>;",
  82. "Ljava/lang/String;",
  83. "[",
  84. "Ljava/lang/Class;",
  85. ")",
  86. "Ljava/lang/reflect/Method;"
  87. }
  88. .end annotation
  89. const/4 v0, 0x0
  90. :try_start_0
  91. invoke-virtual {p0, p1, p2}, Ljava/lang/Class;->getMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
  92. move-result-object p0
  93. :try_end_0
  94. .catch Ljava/lang/NoSuchMethodException; {:try_start_0 .. :try_end_0} :catch_0
  95. :try_start_1
  96. invoke-virtual {p0}, Ljava/lang/reflect/Method;->getModifiers()I
  97. move-result p1
  98. :try_end_1
  99. .catch Ljava/lang/NoSuchMethodException; {:try_start_1 .. :try_end_1} :catch_1
  100. and-int/lit8 p1, p1, 0x1
  101. if-nez p1, :cond_0
  102. :catch_0
  103. move-object p0, v0
  104. :catch_1
  105. :cond_0
  106. return-object p0
  107. .end method
  108. # virtual methods
  109. .method public varargs invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
  110. .locals 3
  111. .annotation system Ldalvik/annotation/Signature;
  112. value = {
  113. "(TT;[",
  114. "Ljava/lang/Object;",
  115. ")",
  116. "Ljava/lang/Object;"
  117. }
  118. .end annotation
  119. .annotation system Ldalvik/annotation/Throws;
  120. value = {
  121. Ljava/lang/reflect/InvocationTargetException;
  122. }
  123. .end annotation
  124. invoke-virtual {p1}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
  125. move-result-object v0
  126. invoke-direct {p0, v0}, Lokhttp3/internal/platform/OptionalMethod;->getMethod(Ljava/lang/Class;)Ljava/lang/reflect/Method;
  127. move-result-object v0
  128. if-eqz v0, :cond_0
  129. :try_start_0
  130. invoke-virtual {v0, p1, p2}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
  131. move-result-object p1
  132. :try_end_0
  133. .catch Ljava/lang/IllegalAccessException; {:try_start_0 .. :try_end_0} :catch_0
  134. return-object p1
  135. :catch_0
  136. move-exception p1
  137. new-instance p2, Ljava/lang/AssertionError;
  138. new-instance v1, Ljava/lang/StringBuilder;
  139. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  140. const-string v2, "Unexpectedly could not call: "
  141. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  142. invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  143. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  144. move-result-object v0
  145. invoke-direct {p2, v0}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
  146. invoke-virtual {p2, p1}, Ljava/lang/AssertionError;->initCause(Ljava/lang/Throwable;)Ljava/lang/Throwable;
  147. throw p2
  148. :cond_0
  149. new-instance p2, Ljava/lang/AssertionError;
  150. new-instance v0, Ljava/lang/StringBuilder;
  151. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  152. const-string v1, "Method "
  153. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  154. iget-object v1, p0, Lokhttp3/internal/platform/OptionalMethod;->methodName:Ljava/lang/String;
  155. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  156. const-string v1, " not supported for object "
  157. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  158. invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  159. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  160. move-result-object p1
  161. invoke-direct {p2, p1}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
  162. throw p2
  163. .end method
  164. .method public varargs invokeOptional(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
  165. .locals 2
  166. .annotation system Ldalvik/annotation/Signature;
  167. value = {
  168. "(TT;[",
  169. "Ljava/lang/Object;",
  170. ")",
  171. "Ljava/lang/Object;"
  172. }
  173. .end annotation
  174. .annotation system Ldalvik/annotation/Throws;
  175. value = {
  176. Ljava/lang/reflect/InvocationTargetException;
  177. }
  178. .end annotation
  179. invoke-virtual {p1}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
  180. move-result-object v0
  181. invoke-direct {p0, v0}, Lokhttp3/internal/platform/OptionalMethod;->getMethod(Ljava/lang/Class;)Ljava/lang/reflect/Method;
  182. move-result-object v0
  183. const/4 v1, 0x0
  184. if-nez v0, :cond_0
  185. return-object v1
  186. :cond_0
  187. :try_start_0
  188. invoke-virtual {v0, p1, p2}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
  189. move-result-object p1
  190. :try_end_0
  191. .catch Ljava/lang/IllegalAccessException; {:try_start_0 .. :try_end_0} :catch_0
  192. return-object p1
  193. :catch_0
  194. return-object v1
  195. .end method
  196. .method public varargs invokeOptionalWithoutCheckedException(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
  197. .locals 1
  198. .annotation system Ldalvik/annotation/Signature;
  199. value = {
  200. "(TT;[",
  201. "Ljava/lang/Object;",
  202. ")",
  203. "Ljava/lang/Object;"
  204. }
  205. .end annotation
  206. :try_start_0
  207. invoke-virtual {p0, p1, p2}, Lokhttp3/internal/platform/OptionalMethod;->invokeOptional(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
  208. move-result-object p1
  209. :try_end_0
  210. .catch Ljava/lang/reflect/InvocationTargetException; {:try_start_0 .. :try_end_0} :catch_0
  211. return-object p1
  212. :catch_0
  213. move-exception p1
  214. invoke-virtual {p1}, Ljava/lang/reflect/InvocationTargetException;->getTargetException()Ljava/lang/Throwable;
  215. move-result-object p1
  216. instance-of p2, p1, Ljava/lang/RuntimeException;
  217. if-eqz p2, :cond_0
  218. check-cast p1, Ljava/lang/RuntimeException;
  219. throw p1
  220. :cond_0
  221. new-instance p2, Ljava/lang/AssertionError;
  222. const-string v0, "Unexpected exception"
  223. invoke-direct {p2, v0}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
  224. invoke-virtual {p2, p1}, Ljava/lang/AssertionError;->initCause(Ljava/lang/Throwable;)Ljava/lang/Throwable;
  225. throw p2
  226. .end method
  227. .method public varargs invokeWithoutCheckedException(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
  228. .locals 1
  229. .annotation system Ldalvik/annotation/Signature;
  230. value = {
  231. "(TT;[",
  232. "Ljava/lang/Object;",
  233. ")",
  234. "Ljava/lang/Object;"
  235. }
  236. .end annotation
  237. :try_start_0
  238. invoke-virtual {p0, p1, p2}, Lokhttp3/internal/platform/OptionalMethod;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
  239. move-result-object p1
  240. :try_end_0
  241. .catch Ljava/lang/reflect/InvocationTargetException; {:try_start_0 .. :try_end_0} :catch_0
  242. return-object p1
  243. :catch_0
  244. move-exception p1
  245. invoke-virtual {p1}, Ljava/lang/reflect/InvocationTargetException;->getTargetException()Ljava/lang/Throwable;
  246. move-result-object p1
  247. instance-of p2, p1, Ljava/lang/RuntimeException;
  248. if-eqz p2, :cond_0
  249. check-cast p1, Ljava/lang/RuntimeException;
  250. throw p1
  251. :cond_0
  252. new-instance p2, Ljava/lang/AssertionError;
  253. const-string v0, "Unexpected exception"
  254. invoke-direct {p2, v0}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
  255. invoke-virtual {p2, p1}, Ljava/lang/AssertionError;->initCause(Ljava/lang/Throwable;)Ljava/lang/Throwable;
  256. throw p2
  257. .end method
  258. .method public isSupported(Ljava/lang/Object;)Z
  259. .locals 0
  260. .annotation system Ldalvik/annotation/Signature;
  261. value = {
  262. "(TT;)Z"
  263. }
  264. .end annotation
  265. invoke-virtual {p1}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
  266. move-result-object p1
  267. invoke-direct {p0, p1}, Lokhttp3/internal/platform/OptionalMethod;->getMethod(Ljava/lang/Class;)Ljava/lang/reflect/Method;
  268. move-result-object p1
  269. if-eqz p1, :cond_0
  270. const/4 p1, 0x1
  271. goto :goto_0
  272. :cond_0
  273. const/4 p1, 0x0
  274. :goto_0
  275. return p1
  276. .end method