Okhttp 的 retrofit2 运行警告信息异常

最近在使用一个 okhttp 的项目运行的时候得到下面的警告信息。

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by retrofit2.Platform (file:/C:/Users/yhu/.m2/repository/com/squareup/retrofit2/retrofit/2.9.0/retrofit-2.9.0.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of retrofit2.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

针对这个问题,已经有官方的说明, 说明的地址为:Illegal reflective access · Issue #3341 · square/retrofit · GitHub

解决办法

我们可以有下面的一些解决方案:

  1. 可以持续使用 Retrofit 2.8.x 或者更新的版本,或者你可以使用 JDK 17 的版本。
  2. 如果你不想升级 JDK 版本的话,你可以继续使用 Retrofit 2.7 版本来避免这个问题。
CWIKI 文章被收录于专栏

CWIKI 项目

全部评论
Retrofit2.7在使用的时候要注意些什么呢?
点赞 回复 分享
发布于 2023-03-25 21:33 四川
升级版本后会有什么不同吗?
点赞 回复 分享
发布于 2023-03-25 21:21 湖南

相关推荐

有担当的灰太狼又在摸鱼:零帧起手查看图片
点赞 评论 收藏
分享
05-14 20:34
门头沟学院 Java
窝补药贝八股:管他们,乱说,反正又不去,直接说680
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务