Read a Kotlin library API from a compiled jar
Read a Kotlin library API from a compiled jar: suspend, nullability, properties, default arguments, and class-file signatures from @Metadata.
A Java decompiler or javap shows the JVM projection of a Kotlin class file. A suspend function gains a trailing Continuation parameter and often returns Object. A default argument becomes a $default synthetic. A property becomes a getter. Nullability is erased. A file of top-level functions becomes a *Kt class, and a multi-file facade splits into part classes such as BuildersKt__BuildersKt. jdx reads the Kotlin @Metadata annotation and prints the Kotlin declaration. Nullability on parameters, returns, and properties is that rendering (v1.7.0, #13). File facades and multi-file parts use the same view (#12). jdx needs Java 21 or later, runs on Linux, macOS, and Windows, and is Apache-2.0. Text is the default, and every command accepts --json. An ambiguous reference exits 2 and lists every candidate. jdx does not guess. Install with the one-line installer. Every command output on this page was produced by running that command when the page was built.
Finding which file holds the class is Find which JAR contains a class. One method of a Java class, or a decompilation when you want the bytecode, is Read and decompile a JAR from the terminal. The comment on a symbol is Read Javadoc from a jar.
Open the class#
jdx show prints the class card: kind, modifiers, supertypes, and member counts. A Kotlin class has a kotlin line under the supertypes. The next: line is the following command.
The examples use org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0, the JVM class jar of kotlinx-coroutines-core. --fetch allows a download when the coordinate is not already in ~/.gradle/caches or ~/.m2. Each --coord example on this page passes it, so any one of them can be copied on its own. A coordinate is not downloaded without that flag. The coordinate without -jvm resolves an artifact that does not contain these classes.
BuildersKt is the multi-file facade. BuildersKt__Builders_commonKt is one part class inside the same jar.
jdx show kotlinx.coroutines.BuildersKt --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch --no-jdk
class kotlinx.coroutines.BuildersKt
public final class BuildersKt
extends java.lang.Object
kotlin
members: 0 constructors, 11 methods, 0 fields
source: kotlinx-coroutines-core-jvm-1.11.0.jar (bytecode)
next: jdx members kotlinx.coroutines.BuildersKt --inherited
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)
jdx show kotlinx.coroutines.BuildersKt__Builders_commonKt --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch --no-jdk
class kotlinx.coroutines.BuildersKt__Builders_commonKt
final class BuildersKt__Builders_commonKt
extends java.lang.Object
kotlin
members: 0 constructors, 7 methods, 3 fields
source: kotlinx-coroutines-core-jvm-1.11.0.jar (bytecode)
next: jdx members kotlinx.coroutines.BuildersKt__Builders_commonKt --inherited
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
kotlinx-coroutines-core-jvm 1.11.0 is a multi-release jar, so jdx warns MULTI_RELEASE_VARIANT and still prints the card. The same warning appears on the other commands on this page.
Reference: show.
Suspend, and the Continuation parameter#
jdx signature prints one declaration line per matching member. The default --view is kotlin. Flow.collect is suspend. The Kotlin line has no Continuation parameter.
jdx signature 'kotlinx.coroutines.flow.FlowKt#collect' --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch
signatures of kotlinx.coroutines.flow.FlowKt#collect
public static final suspend void collect(kotlinx.coroutines.flow.Flow<?> $this$collect)
source: kotlinx-coroutines-core-jvm-1.11.0.jar (bytecode)
next: jdx show kotlinx.coroutines.flow.FlowKt
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)
jdx signature 'kotlinx.coroutines.flow.FlowKt#collect' --view jvm --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch
signatures of kotlinx.coroutines.flow.FlowKt#collect
public static final java.lang.Object collect(kotlinx.coroutines.flow.Flow<?> $this$collect, kotlin.coroutines.Continuation<? super kotlin.Unit> $completion)
source: kotlinx-coroutines-core-jvm-1.11.0.jar (bytecode)
next: jdx show kotlinx.coroutines.flow.FlowKt
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
--view jvm is the class-file signature: the return type is java.lang.Object, and the last parameter is kotlin.coroutines.Continuation. That is the method a stack trace and javap name. The Kotlin view is what a Kotlin caller writes.
Always quote references in a shell: #, (, and $ are shell syntax. The reference grammar is Symbol references.
Reference: signature.
Nullability and properties#
Job.parent is a property. The Kotlin signature carries the ? from @Metadata. The JVM getter is getParent, and its return type has no ?.
jdx signature 'kotlinx.coroutines.Job#parent' --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch --no-jdk
signatures of kotlinx.coroutines.Job#parent
public abstract val kotlinx.coroutines.Job? parent
source: kotlinx-coroutines-core-jvm-1.11.0.jar (bytecode)
next: jdx show kotlinx.coroutines.Job
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)
jdx signature 'kotlinx.coroutines.Job#getParent' --view jvm --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch --no-jdk
signatures of kotlinx.coroutines.Job#getParent
public abstract kotlinx.coroutines.Job getParent()
source: kotlinx-coroutines-core-jvm-1.11.0.jar (bytecode)
next: jdx show kotlinx.coroutines.Job
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
The ? is display text on the declaration line. The canonical reference on the first line has no ?. Pasting a ? into a later reference is accepted, and the parsed ref drops it. jdx members --kind property lists properties. --kind method lists methods. The default --kind is all.
A metadata type with no Java spelling stays the JVM type. Names such as String and List are spelled. kotlin.sequences.Sequence is not, so a property of that type stays the erased JVM type. Job? spells, because kotlinx.coroutines.Job has a Java name.
Default arguments and @JvmName#
A parameter @Metadata records as defaulted is marked = .... On runBlocking that parameter is context.
jdx signature 'kotlinx.coroutines.BuildersKt#runBlocking' --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch --no-jdk
signatures of kotlinx.coroutines.BuildersKt#runBlocking
public static final <T> T runBlocking(kotlin.coroutines.CoroutineContext context = ..., kotlin.jvm.functions.Function2<? super kotlinx.coroutines.CoroutineScope, ? super kotlin.coroutines.Continuation<? super T>, ? extends java.lang.Object> block) throws java.lang.InterruptedException
public static final <T> T runBlocking(kotlin.coroutines.CoroutineContext context = ..., kotlin.jvm.functions.Function2<? super kotlinx.coroutines.CoroutineScope, ? super kotlin.coroutines.Continuation<? super T>, ? extends java.lang.Object> block)
source: kotlinx-coroutines-core-jvm-1.11.0.jar (bytecode)
next: jdx show kotlinx.coroutines.BuildersKt
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
The compiler also emits a synthetic for the defaulted call. It is hidden in the Kotlin view. --view jvm --include-synthetic prints it. --grep is a Java regex matched against the member name. ^launch matches launch and launch$default.
jdx members kotlinx.coroutines.BuildersKt --declared --kind method --include-synthetic --view jvm --grep '^launch' --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch
members of kotlinx.coroutines.BuildersKt
methods declared on kotlinx.coroutines.BuildersKt:
method public static final kotlinx.coroutines.Job launch(kotlinx.coroutines.CoroutineScope $this$launch, kotlin.coroutines.CoroutineContext context, kotlinx.coroutines.CoroutineStart start, kotlin.jvm.functions.Function2<? super kotlinx.coroutines.CoroutineScope, ? super kotlin.coroutines.Continuation<? super kotlin.Unit>, ? extends java.lang.Object> block)
method public static kotlinx.coroutines.Job launch$default(kotlinx.coroutines.CoroutineScope arg0, kotlin.coroutines.CoroutineContext arg1, kotlinx.coroutines.CoroutineStart arg2, kotlin.jvm.functions.Function2 arg3, int arg4, java.lang.Object arg5)
source: kotlinx-coroutines-core-jvm-1.11.0.jar (bytecode)
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
@JvmName is the other rename. Querying the JVM name debounceDuration still resolves. The Kotlin view prints debounce. --view jvm prints debounceDuration.
jdx signature 'kotlinx.coroutines.flow.FlowKt#debounceDuration' --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch
signatures of kotlinx.coroutines.flow.FlowKt#debounceDuration
public static final <T> kotlinx.coroutines.flow.Flow<T> debounce(kotlinx.coroutines.flow.Flow<? extends T> $this$debounce, kotlin.jvm.functions.Function1<? super T, kotlin.time.Duration> timeout)
source: kotlinx-coroutines-core-jvm-1.11.0.jar (bytecode)
next: jdx show kotlinx.coroutines.flow.FlowKt
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)
jdx signature 'kotlinx.coroutines.flow.FlowKt#debounceDuration' --view jvm --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch
signatures of kotlinx.coroutines.flow.FlowKt#debounceDuration
public static final <T> kotlinx.coroutines.flow.Flow<T> debounceDuration(kotlinx.coroutines.flow.Flow<? extends T> $this$debounce, kotlin.jvm.functions.Function1<? super T, kotlin.time.Duration> timeout)
source: kotlinx-coroutines-core-jvm-1.11.0.jar (bytecode)
next: jdx show kotlinx.coroutines.flow.FlowKt
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
Reference: members. --declared is only the type's own members. Inherited members are the default.
File facades and multi-file parts#
Top-level Kotlin functions compile to a *Kt class. A multi-file facade is an umbrella class plus one part class per file. jdx search lists the part classes in this jar:
jdx search 'BuildersKt__*' --kind class --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch --no-jdk
search results for 'BuildersKt__*'
class kotlinx.coroutines.BuildersKt__BuildersKt kotlinx-coroutines-core-jvm-1.11.0.jar
class kotlinx.coroutines.BuildersKt__Builders_commonKt kotlinx-coroutines-core-jvm-1.11.0.jar
class kotlinx.coroutines.BuildersKt__Builders_concurrentKt kotlinx-coroutines-core-jvm-1.11.0.jar
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
runBlocking is declared on the part BuildersKt__BuildersKt. The umbrella BuildersKt lists it too. jdx merges each part's metadata into the umbrella when the jar is open, so the name a Kotlin caller uses and the part name from a stack trace both answer.
jdx members kotlinx.coroutines.BuildersKt --declared --kind method --grep '^runBlocking$' --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch
members of kotlinx.coroutines.BuildersKt
methods declared on kotlinx.coroutines.BuildersKt:
method public static final <T> T runBlocking(kotlin.coroutines.CoroutineContext context = ..., kotlin.jvm.functions.Function2<? super kotlinx.coroutines.CoroutineScope, ? super kotlin.coroutines.Continuation<? super T>, ? extends java.lang.Object> block) throws java.lang.InterruptedException
source: kotlinx-coroutines-core-jvm-1.11.0.jar (bytecode)
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)
jdx members kotlinx.coroutines.BuildersKt__BuildersKt --declared --kind method --grep '^runBlocking$' --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch
members of kotlinx.coroutines.BuildersKt__BuildersKt
methods declared on kotlinx.coroutines.BuildersKt__BuildersKt:
method public static final <T> T runBlocking(kotlin.coroutines.CoroutineContext context = ..., kotlin.jvm.functions.Function2<? super kotlinx.coroutines.CoroutineScope, ? super kotlin.coroutines.Continuation<? super T>, ? extends java.lang.Object> block) throws java.lang.InterruptedException
source: kotlinx-coroutines-core-jvm-1.11.0.jar (bytecode)
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
^runBlocking$ keeps runBlockingImpl and runBlockingK out of the list. Corrupt or missing metadata falls back to the JVM projection for that class. The command still prints the members.
Reference: search.
One method body#
jdx body prints one member. members and signature come from bytecode either way. The body is real source when a paired sources file can be sliced, and a reconstruction when it cannot.
This coordinate publishes no -sources.jar that jdx pairs. The facade method is labelled ⚠ reconstructed, and the provenance names the engine. Here the engine is javap: the line shows the class-file body, a single call into BuildersKt__Builders_commonKt.launch.
jdx body 'kotlinx.coroutines.BuildersKt#launch(kotlinx.coroutines.CoroutineScope, kotlin.coroutines.CoroutineContext, kotlinx.coroutines.CoroutineStart, kotlin.jvm.functions.Function2)' --max-lines 20 --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch
kotlinx.coroutines.BuildersKt#launch(kotlinx.coroutines.CoroutineScope, kotlin.coroutines.CoroutineContext, kotlinx.coroutines.CoroutineStart, kotlin.jvm.functions.Function2)
source: disassembled by javap from kotlinx-coroutines-core-jvm-1.11.0.jar · kotlinx/coroutines/BuildersKt.java:29-37 ⚠ reconstructed
public static final kotlinx.coroutines.Job launch(kotlinx.coroutines.CoroutineScope, kotlin.coroutines.CoroutineContext, kotlinx.coroutines.CoroutineStart, kotlin.jvm.functions.Function2<? super kotlinx.coroutines.CoroutineScope, ? super kotlin.coroutines.Continuation<? super kotlin.Unit>, ? extends java.lang.Object>);
descriptor: (Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;Lkotlinx/coroutines/CoroutineStart;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/Job;
Code:
0: aload_0
1: aload_1
2: aload_2
3: aload_3
4: invokestatic #39 // Method kotlinx/coroutines/BuildersKt__Builders_commonKt.launch:(Lkotlinx/coroutines/CoroutineScope;Lkotlin/coroutines/CoroutineContext;Lkotlinx/coroutines/CoroutineStart;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/Job;
7: areturn
next: jdx show kotlinx.coroutines.BuildersKt
warning MULTI_RELEASE_VARIANT: multi-release kotlinx-coroutines-core-jvm-1.11.0.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
jdx doc on the same jar exits 1. There is no paired sources file, and a reconstructed class file has no KDoc to read. The parenthetical is the tool's own words:
jdx doc kotlinx.coroutines.Job --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch
not found: kotlinx.coroutines.Job
no sources for kotlinx.coroutines.Job in kotlinx-coroutines-core-jvm-1.11.0.jar (decompilation not yet implemented, T-026)
[exit 1]Real output — this example ran against the current jdx when the page was built.
Kotlin sources need one install#
Slicing a .kt member and reading KDoc use the Kotlin compiler parser. It is not inside the jdx jar. jdx kotlin install downloads the pinned compiler jars, checks SHA-1, and stores them under <cache-dir>/kotlin/ (~/.cache/jdx/kotlin/ on Linux). Jars already present are skipped, so the network is used for that download and not on later queries. --force re-downloads. jdx doctor reports whether the sidecar is installed.
jdx kotlin installjdx members and jdx signature do not need it. They read @Metadata from the class file.
kotlin-stdlib 2.1.21 does publish a -sources.jar. jdx source kotlin.Unit prints Unit.kt, because that path is a direct hit and a whole file is not parsed. jdx doc on the same class exits 1 and names jdx kotlin install. jdx body of toString is still ⚠ reconstructed.
jdx source kotlin.Unit --max-lines 8 --coord org.jetbrains.kotlin:kotlin-stdlib:2.1.21 --fetch
kotlin.Unit
source: kotlin-stdlib-2.1.21-sources.jar · commonMain/kotlin/Unit.kt:1-11
/*
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package kotlin
/**
… 3 more lines (run it yourself to see them all)Real output — this example ran against the current jdx when the page was built.
jdx doc kotlin.Unit --coord org.jetbrains.kotlin:kotlin-stdlib:2.1.21 --fetch
not found: kotlin.Unit
kotlin.Unit only ships Kotlin sources here (kotlin-compiler-embeddable-2.4.20.jar not installed under <cache-dir>/kotlin (Kotlin sources unavailable — run `jdx kotlin install` to fetch it, see `jdx doctor`))
[exit 1]
jdx body 'kotlin.Unit#toString()' --max-lines 12 --coord org.jetbrains.kotlin:kotlin-stdlib:2.1.21 --fetch
kotlin.Unit#toString()
source: disassembled by javap from kotlin-stdlib-2.1.21.jar · kotlin/Unit.java:13-17 ⚠ reconstructed
public java.lang.String toString();
descriptor: ()Ljava/lang/String;
Code:
0: ldc #15 // String kotlin.Unit
2: areturn
next: jdx show kotlin.Unit
warning MULTI_RELEASE_VARIANT: multi-release kotlin-stdlib-2.1.21.jar serves version-specific variants for this JDK (21)Real output — this example ran against the current jdx when the page was built.
A file you already have is --jars (a jar, a class directory, or a glob). Quote the glob so the shell does not expand it. An unquoted expansion exits 3. --no-jdk leaves the JDK out.
jdx signature 'kotlinx.coroutines.Job#parent' --jars path/to/library.jar --no-jdk
jdx members com.example.ApiKt --declared --kind method --jars 'libs/*.jar' --no-jdkInside a Gradle or Maven project, with no classpath flags, jdx discovers project classes and the dependency jars named in the build files. It never runs Gradle or Maven to do that. See Classpath & workspaces. The rest of the Kotlin rules are in Reading code.
From an AI agent#
The same Kotlin view is what an agent gets from jdx mcp. jdx_members and jdx_signature take view: kotlin (the default) or jvm. jdx_show is the class card. jdx_body is the one member, reconstructed and labelled when the .kt slice is unavailable. The server never downloads, and it does not take a jar path or a Maven coordinate on the call. Create a workspace with the CLI, then start the server on it. A tool call may pass workspace to pick another stored name. Prime a coordinate with --fetch first, or pass files you already have.
jdx show kotlinx.coroutines.BuildersKt --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch
jdx ws create coroutines --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0
jdx mcp -w coroutines
jdx setup --agent claude-code --scope project
jdx setup --agent cursor --scope project
jdx setup --agent codex --scope projectjdx setup writes args as mcp only. Add -w by hand when the workspace is not default. Per-agent pages are on integrations. The config shapes are in An MCP server for Java and Kotlin bytecode.
Reference: jdx_members, jdx_signature.
Bytecode is parsed with ASM. Inspected classes are never loaded, so no static initialiser from the jar runs. jdx writes only inside its own cache, config, and runtime directories.
FAQ#
How do I read a Kotlin library API from a jar?#
jdx show kotlinx.coroutines.BuildersKt --coord org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.11.0 --fetch prints the class card. jdx members lists what you can call. jdx signature prints one declaration. The default view is the Kotlin declaration from @Metadata. Install jdx with the one-line installer. Java 21 or later is required.
Why does a decompiled Kotlin suspend function take Continuation?#
The class file appends kotlin.coroutines.Continuation and often returns java.lang.Object. jdx signature 'kotlinx.coroutines.flow.FlowKt#collect' prints suspend and omits that parameter. jdx signature ... --view jvm prints the class-file signature, including Continuation.
How do I see nullability in a decompiled Kotlin jar?#
jdx signature 'kotlinx.coroutines.Job#parent' prints val kotlinx.coroutines.Job? parent. The JVM getter getParent returns Job with no ?. The marker comes from @Metadata (v1.7.0). A reconstructed method body does not add it back. The ? stays on the declaration line. The canonical reference omits it.
How do I view Kotlin metadata in a jar?#
jdx decodes @Metadata while it renders jdx members and jdx signature. There is no separate metadata dump. --view kotlin is the default. --view jvm is the class file: getters, Continuation, $default, and @JvmName JVM names. A file facade and its multi-file parts both render from that metadata (#12).
Does reading a Kotlin jar need jdx kotlin install?#
Not for declarations. jdx members and jdx signature read @Metadata with no extra download. jdx kotlin install is once, for KDoc and for slicing a .kt member. Without it, jdx doc on Kotlin sources exits 1 and names the install command, and jdx body is labelled ⚠ reconstructed. The network is that install, plus --fetch when you ask to download a coordinate.
Where next#
jdx signature— every flag, generated from the binary.jdx members— filters,--view, and--kind property.- Read and decompile a JAR from the terminal — one method, source, or a decompilation.
- Read Javadoc from a jar — the comment, from a paired
-sources.jar. - Find which JAR contains a class — which file holds a class.
- Reading code — the Kotlin view,
--view jvm, and the sidecar. - An MCP server for Java and Kotlin bytecode —
jdx mcpfor Claude Code, Cursor, and Codex. - Installation — Linux, macOS, Windows, and offline installs.
- Symbol references — how to paste a canonical ref.
- Classpath & workspaces —
--jars,--coord, andjdx ws. - Output, JSON & exit codes — the exit-code table.
- Command catalogue — every flag.