Skip to content

bug: JDK17下Patch方法报错 java.lang.reflect.InaccessibleObjectException: #3613

Closed Answered by looly
Mujio-killer asked this question in Q&A
Discussion options

You must be logged in to vote

Hutool为了让JDK支持patch方法,通过反射修改了java.net.HttpURLConnection中的数组,JDK17中对反射使用做了严格限制,导致反射失败。

你可以:

  1. 使用HttpClient之类的库避免使用JDK的
  2. 使用JVM启动参数允许反射:
--add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Mujio-killer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants