khttp
khttp copied to clipboard
Illegal reflective access on khttp.requests.GenericRequest
Description
The class khttp.requests.GenericRequest
uses reflection to access the setter for URL#host
and URL#authority
On JDK 11+, this causes a warning to be printed to the console, which will turn into an exception in the future.
This can be fixed by changing the method to something like:
private fun URL.toIDN(): URL {
val newHost = IDN.toASCII(this.host)
// Not sure how to fix this one
// this.javaClass.getDeclaredField("authority").apply { this.isAccessible = true }.set(this, if (this.port == -1) this.host else "${this.host}:${this.port}")
val query = if (this.query == null) {
null
} else {
URLDecoder.decode(this.query, "UTF-8")
}
return URL(URI(this.protocol, this.userInfo, newHost, this.port, this.path, query, this.ref).toASCIIString())
}
I am unsure how to change authority
from using reflection. If anyone has any ideas please let me know.
@cbyrneee Is this project abandonware? I'm thinking I should move my code to something more well supported. What did you end up doing?