diff --git a/okhttp/src/main/kotlin/okhttp3/internal/platform/Platform.kt b/okhttp/src/main/kotlin/okhttp3/internal/platform/Platform.kt index 664f913964a1..9e0c362d6787 100644 --- a/okhttp/src/main/kotlin/okhttp3/internal/platform/Platform.kt +++ b/okhttp/src/main/kotlin/okhttp3/internal/platform/Platform.kt @@ -94,6 +94,14 @@ open class Platform { val context = readFieldOrNull(sslSocketFactory, sslContextClass, "context") ?: return null readFieldOrNull(context, X509TrustManager::class.java, "trustManager") } catch (e: ClassNotFoundException) { + null + } catch (e: RuntimeException) { + // Throws InaccessibleObjectException (added in JDK9) on JDK 17 due to + // JEP 403 Strongly Encapsulate JDK Internals. + if (e.javaClass.name != "java.lang.reflect.InaccessibleObjectException") { + throw e + } + null } }