or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/maven-org-jetbrains-kotlin--kotlin-stdlib-jre8

Kotlin Standard Library JRE 8 extension providing enhanced integration with Java 8 features such as Stream API conversions, regex enhancements, and collection utilities

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.jetbrains.kotlin/kotlin-stdlib-jre8@1.2.x

To install, run

npx @tessl/cli install tessl/maven-org-jetbrains-kotlin--kotlin-stdlib-jre8@1.2.0

index.mddocs/

Kotlin Standard Library JRE 8 Extension

The Kotlin Standard Library JRE 8 Extension provides enhanced integration with Java 8 specific features. This package offers bidirectional conversion between Kotlin sequences and Java 8 streams, regex enhancements with named group support, and collection utilities optimized for JRE 8.

Note: This package is deprecated in favor of kotlin-stdlib-jdk8 which provides the same functionality with updated naming conventions.

Package Information

  • Package Name: kotlin-stdlib-jre8
  • Package Type: maven
  • Language: Kotlin
  • Installation: implementation 'org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.71'

Core Imports

import kotlin.streams.*
import kotlin.text.*

Basic Usage

import kotlin.streams.*
import java.util.stream.Stream

// Convert Java 8 Stream to Kotlin Sequence
val stream = Stream.of("apple", "banana", "cherry")
val sequence = stream.asSequence()

// Convert Kotlin Sequence back to Java 8 Stream
val backToStream = sequence.asStream()

// Collect stream directly to List
val list = Stream.of(1, 2, 3, 4, 5).toList()
println(list) // [1, 2, 3, 4, 5]

Capabilities

Stream to Sequence Conversion

Convert Java 8 Stream types to Kotlin Sequences for functional programming integration.

/**
 * Creates a Sequence instance that wraps the original stream iterating through its elements
 */
fun <T> Stream<T>.asSequence(): Sequence<T>

/**
 * Creates a Sequence instance that wraps the original IntStream iterating through its elements  
 */
fun IntStream.asSequence(): Sequence<Int>

/**
 * Creates a Sequence instance that wraps the original LongStream iterating through its elements
 */
fun LongStream.asSequence(): Sequence<Long>

/**
 * Creates a Sequence instance that wraps the original DoubleStream iterating through its elements
 */
fun DoubleStream.asSequence(): Sequence<Double>

Sequence to Stream Conversion

Convert Kotlin Sequences to Java 8 Streams for interoperability with Java APIs.

/**
 * Creates a sequential Stream instance that produces elements from the original sequence
 */
fun <T> Sequence<T>.asStream(): Stream<T>

Stream to List Collection

Collect Java 8 Stream elements directly to Kotlin Lists.

/**
 * Returns a List containing all elements produced by this stream
 */
fun <T> Stream<T>.toList(): List<T>

/**
 * Returns a List containing all elements produced by this IntStream
 */
fun IntStream.toList(): List<Int>

/**
 * Returns a List containing all elements produced by this LongStream
 */
fun LongStream.toList(): List<Long>

/**
 * Returns a List containing all elements produced by this DoubleStream
 */
fun DoubleStream.toList(): List<Double>

Usage Examples:

import kotlin.streams.*
import java.util.stream.Stream
import java.util.stream.IntStream

// Stream to Sequence conversion
val stream = Stream.of("hello", "world", "kotlin")
val sequence = stream.asSequence()
val uppercased = sequence.map { it.uppercase() }.toList()

// IntStream to List
val numbers = IntStream.range(1, 6).toList() // [1, 2, 3, 4, 5]

// Sequence to Stream
val kotlinSequence = sequenceOf(1, 2, 3, 4, 5)
val javaStream = kotlinSequence.asStream()
val sum = javaStream.mapToInt { it }.sum()

Regex Named Groups

Enhanced regex functionality with named capture group support.

/**
 * Returns a named group with the specified name
 * @param name The name of the capture group
 * @return An instance of MatchGroup if the group was matched, null otherwise
 * @throws UnsupportedOperationException if getting named groups isn't supported on the current platform
 */
operator fun MatchGroupCollection.get(name: String): MatchGroup?

Usage Examples:

import kotlin.text.*

val regex = "(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})".toRegex()
val matchResult = regex.find("2023-12-25")
if (matchResult != null) {
    val year = matchResult.groups["year"]?.value  // "2023"
    val month = matchResult.groups["month"]?.value // "12"
    val day = matchResult.groups["day"]?.value    // "25"
}

Types

All functions use standard Kotlin and Java types:

// Java 8 Stream types
java.util.stream.Stream<T>
java.util.stream.IntStream  
java.util.stream.LongStream
java.util.stream.DoubleStream

// Kotlin types
kotlin.sequences.Sequence<T>
kotlin.collections.List<T>
kotlin.text.MatchGroup
kotlin.text.MatchGroupCollection

Version Compatibility

  • Kotlin Version: 1.2.71
  • Java Version: JRE/JDK 8+
  • Since: Kotlin 1.1 (all public functions annotated with @SinceKotlin("1.1"))

Migration Notice

This package is deprecated. For new projects or when updating dependencies, use kotlin-stdlib-jdk8 instead:

// Old (deprecated)
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.71'

// New (recommended)  
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71'

The API remains the same between both packages.