How to use jdk.internal package with Gradle?

353 Views Asked by At

For example, if I'd like to add an extension on Inet4Address to be able to directly retrieve the underlying 32-bit address as an Int:

import jdk.internal.access.SharedSecrets

val Inet4Address.value
        get() = SharedSecrets.getJavaNetInetAddressAccess().addressValue(this)

IntelliJ IDEA does not show any errors, auto-complete works fine for it, etc.

However, when Gradle compileKotlin runs, I get these compilation errors:

Unresolved reference: access
Unresolved reference: SharedSecrets

This happens despite using a Java 11 toolchain spec in my build.gradle.kts:

java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(11))
    }
}

How can I go about giving Kotlin access to the jdk.internal package with Gradle?

0

There are 0 best solutions below