When I try to use named groups in a kotlin.text.Regex in my build.gradle, I get the following exception:
“Retrieving groups by name is not supported on this platform.”
I just noticed, you don’t even need the classpath-dependency… gradle seems to have kotlin as default on the classpath.
Maybe thats the problem, that gradle has a non-jre8 kotlin on the default classpath?
I suppose the problem is that Gradle loads its bundled kotlin-stdlib in a separate classloader than the other classpath dependencies. So when stdlib tries to discover the extensions provided by kotlin-stdlib-jre8, it fails to find them in the same classloader.
The obvious solution is to bundle kotlin-stdlib-jre8 into Gradle, but it isn’t possible while Gradle targets Java 7 as minimal supported JRE.
The implementation selector checks the current java version first, before trying to use the extension library.
I believe Gradle codebase is covered with tests extensively, that run on all supported Java versions, so if they don’t fail, it may be fine then to bundle extension libraries.
By the way, running these tests on JDK 9 has revealed a problem that getting named groups from regex doesn’t work there: https://youtrack.jetbrains.com/issue/KT-20865