CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-jetbrains-kotlinx--kotlinx-coroutines-jdk8

Backwards compatibility stub module for kotlinx-coroutines JDK8 integration functionality, merged with core since 1.7.0

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

kotlinx-coroutines-jdk8

kotlinx-coroutines-jdk8 is a backwards compatibility stub module for Kotlin coroutines JDK8 integration functionality. Since version 1.7.0, the JDK8-specific functionality has been merged directly into the core kotlinx-coroutines library, making this package a transition module that maintains compatibility for existing projects by providing dependency access to the core JDK8 integration APIs.

Package Information

  • Package Name: kotlinx-coroutines-jdk8
  • Package Type: maven
  • Group ID: org.jetbrains.kotlinx
  • Language: Kotlin
  • Installation: implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.10.2")

Core Imports

Since this is a stub module, all JDK8 integration functionality is accessed through imports from the core kotlinx-coroutines library:

// CompletableFuture integration
import kotlinx.coroutines.future.*

// java.time integration  
import kotlinx.coroutines.time.*

// Stream integration
import kotlinx.coroutines.stream.*

// Core coroutines functionality
import kotlinx.coroutines.*

Basic Usage

The most common use case is converting between coroutines and CompletableFuture:

import kotlinx.coroutines.*
import kotlinx.coroutines.future.*
import java.util.concurrent.CompletableFuture

// Start a coroutine and get CompletableFuture
val scope = CoroutineScope(Dispatchers.Default)
val future: CompletableFuture<String> = scope.future {
    delay(1000)
    "Hello from coroutine!"
}

// Convert CompletableFuture to Deferred
val deferred: Deferred<String> = future.asDeferred()

// Await CompletableFuture in suspending context
suspend fun example() {
    val result = future.await()
    println(result)
}

Architecture

This stub module provides access to three main integration areas:

  • Future Integration: Bidirectional conversion between coroutines and CompletableFuture/CompletionStage
  • Time Integration: java.time.Duration adapters for coroutine timing functions
  • Stream Integration: Convert Java 8 Streams to Kotlin Flows

All functionality is implemented in the core kotlinx-coroutines library and accessed transitively through this dependency.

Capabilities

CompletableFuture Integration

Bidirectional conversion between coroutines and Java's CompletableFuture/CompletionStage.

/**
 * Starts a coroutine and returns its result as CompletableFuture
 */
fun <T> CoroutineScope.future(
    context: CoroutineContext = EmptyCoroutineContext,
    start: CoroutineStart = CoroutineStart.DEFAULT,
    block: suspend CoroutineScope.() -> T
): CompletableFuture<T>

/**
 * Converts Deferred to CompletableFuture
 */
fun <T> Deferred<T>.asCompletableFuture(): CompletableFuture<T>

/**
 * Converts Job to CompletableFuture<Unit>
 */
fun Job.asCompletableFuture(): CompletableFuture<Unit>

/**
 * Converts CompletionStage to Deferred
 */
@Suppress("DeferredIsResult")
fun <T> CompletionStage<T>.asDeferred(): Deferred<T>

/**
 * Suspending await for CompletionStage
 */
suspend fun <T> CompletionStage<T>.await(): T

java.time Integration

Adapter methods that accept java.time.Duration parameters for coroutine timing functions.

/**
 * java.time adapter for delay function
 */
suspend fun delay(duration: Duration): Unit

/**
 * java.time adapter for withTimeout
 */
suspend fun <T> withTimeout(
    duration: Duration, 
    block: suspend CoroutineScope.() -> T
): T

/**
 * java.time adapter for withTimeoutOrNull
 */
suspend fun <T> withTimeoutOrNull(
    duration: Duration,
    block: suspend CoroutineScope.() -> T
): T?

/**
 * java.time adapter for Flow.debounce
 */
@FlowPreview
fun <T> Flow<T>.debounce(timeout: Duration): Flow<T>

/**
 * java.time adapter for Flow.sample
 */
@FlowPreview
fun <T> Flow<T>.sample(period: Duration): Flow<T>

/**
 * java.time adapter for SelectBuilder.onTimeout
 */
fun <R> SelectBuilder<R>.onTimeout(
    duration: Duration,
    block: suspend () -> R
): Unit

Stream Integration

Convert Java 8 Streams to Kotlin Flows for seamless integration.

/**
 * Converts Stream to Flow and closes the stream afterwards
 */
fun <T> Stream<T>.consumeAsFlow(): Flow<T>

Types

All types are defined in the core kotlinx-coroutines library:

// From kotlinx.coroutines
interface Job : CoroutineContext.Element
interface Deferred<out T> : Job
class CoroutineScope(context: CoroutineContext)
enum class CoroutineStart
interface CoroutineContext

// From kotlinx.coroutines.flow  
interface Flow<out T>
interface FlowCollector<in T>

// From kotlinx.coroutines.selects
interface SelectBuilder<in R>

// Java types (from JDK)
class CompletableFuture<T>
interface CompletionStage<T>
interface Stream<T>
class Duration

Notes

  • This is a backwards compatibility stub module - no direct API exists in the package itself
  • All functionality is provided through transitive dependency on kotlinx-coroutines-core
  • For new projects, consider depending directly on kotlinx-coroutines-core
  • The module contains only a Java module descriptor (module kotlinx.coroutines.jdk8 {})
  • Recommended migration path: replace dependency with kotlinx-coroutines-core and update imports accordingly
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.jetbrains.kotlinx/kotlinx-coroutines-jdk8@1.10.x
Publish Source
CLI
Badge
tessl/maven-org-jetbrains-kotlinx--kotlinx-coroutines-jdk8 badge