<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Mohammad's dev notes]]></title><description><![CDATA[Mohammad's dev notes]]></description><link>https://mohammadmd1383.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 10:39:30 GMT</lastBuildDate><atom:link href="https://mohammadmd1383.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[What actually changed between two Minecraft versions? Diffing Loom-mapped jars from the terminal]]></title><description><![CDATA[jdx diff names every public-API change between two jars, ordered most severe first, so a Minecraft or mod upgrade stops being guesswork. Honest caveat…]]></description><link>https://mohammadmd1383.hashnode.dev/what-actually-changed-between-two-minecraft-versions-diffing-loom-mapped-jars-from-the-terminal</link><guid isPermaLink="true">https://mohammadmd1383.hashnode.dev/what-actually-changed-between-two-minecraft-versions-diffing-loom-mapped-jars-from-the-terminal</guid><category><![CDATA[minecraft]]></category><category><![CDATA[Java]]></category><category><![CDATA[modding]]></category><category><![CDATA[cli]]></category><category><![CDATA[open source]]></category><dc:creator><![CDATA[Mohammad Mostafa Dastjerdi]]></dc:creator><pubDate>Wed, 25 Nov 2026 10:04:28 GMT</pubDate><content:encoded><![CDATA[<p>Every Minecraft update has the same first hour for a mod developer: the build breaks, and you start opening classes one by one to work out what moved. A renamed method here, a changed parameter type there, a field that is suddenly gone. Release notes rarely cover the API you actually call.</p>
<p>I wanted that first hour to be one command. <a href="https://mohammadmd1383.github.io/jdx/">jdx</a> is an open-source Kotlin CLI and MCP server (v1.7.0, Java 21+, Apache-2.0) that reads JVM bytecode with ASM and never loads or runs the classes it inspects. One of its commands, <code>jdx diff</code>, compares the public API of two artifacts and names every change.</p>
<h2>The one rule that matters: one mapping namespace</h2>
<p>jdx reads the names stored in the file. It does not read mapping files and it does not remap anything. So you give it the jars Loom already wrote for you: the Yarn or Mojmap jar that Fabric Loom or NeoForge ModDevGradle produced.</p>
<p><code>diff</code> only makes sense when both sides use the same names. Compare two Yarn jars, or two Mojmap jars, or two intermediary jars, or two builds of your own mod compiled in one namespace. A Yarn jar against a Mojmap jar shares almost no names, so the report looks like nearly every member was removed and re-added. That comparison is meaningless, and jdx will not pretend otherwise.</p>
<h2>The command</h2>
<pre><code class="language-bash">jdx diff "$OLD_MAPPED_JAR" "$NEW_MAPPED_JAR" --severity breaking --limit 40
jdx diff old-mod.jar new-mod.jar
</code></pre>
<p>The two arguments are the artifacts: a jar file, a class directory, a quoted glob, or a Maven coordinate. There is no classpath and no workspace, so it runs in an empty directory.</p>
<p>The default surface is <code>public</code> (public and protected types and members, the API a caller compiles against). Each finding is one line, <code>severity RULE ref</code>, with rules such as <code>MEMBER_REMOVED</code>, <code>RETURN_TYPE_CHANGED</code> and <code>PARAMETER_TYPE_CHANGED</code>, sorted most severe first. <code>--severity breaking</code> hides everything that cannot break your build, and the tally under the list still describes the whole comparison.</p>
<p>A member's identity is its name plus its erased parameter list, so a covariant return shows up as one <code>RETURN_TYPE_CHANGED</code>, not a removal and an addition. An ambiguous pairing is never guessed: two removals of the same shape stay two removals.</p>
<h2>From finding to fix</h2>
<p>The refs are canonical, so the next step is a copy-paste. The report even ends with a hint like <code>next: jdx members &lt;type&gt;</code>. From there:</p>
<ul>
<li><code>jdx members &lt;type&gt; --jars &lt;mapped jar&gt;</code> shows what the class looks like now</li>
<li><code>jdx signature &lt;ref&gt;</code> shows the exact new signature</li>
<li><code>jdx body &lt;ref&gt;</code> shows the method itself (decompiled with Vineflower and labeled "reconstructed" when there is no sources jar)</li>
</ul>
<p>That is usually enough to rewrite a mixin target or a call site without opening an IDE. If you are choosing a new injection point, the <a href="https://mohammadmd1383.github.io/jdx/docs/minecraft-mixin-targets/">Mixin target guide</a> walks through it.</p>
<h2>Not just Minecraft</h2>
<p>The same command gates library upgrades in CI: <code>jdx diff a b --fail-on breaking</code> exits non-zero when a dependency bump removes or retypes something you rely on. The rule list is in the <a href="https://mohammadmd1383.github.io/jdx/docs/api-diff/">API diff guide</a>.</p>
<h2>Try it</h2>
<pre><code class="language-bash">curl -fsSL https://raw.githubusercontent.com/MohammadMD1383/jdx/main/install-release.sh | bash
</code></pre>
<p>The full walkthrough, with real output, is here: <a href="https://mohammadmd1383.github.io/jdx/docs/minecraft-version-diff/">See what changed between two Minecraft or mod versions</a>. The source is on <a href="https://github.com/MohammadMD1383/jdx">GitHub</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Reading a Kotlin library's real API from a compiled jar (suspend, nullability, default args) without the Java-ified view]]></title><description><![CDATA[If you've ever run javap on a Kotlin jar, you know the problem: you don't see the Kotlin API, you see what the compiler lowered it to. A suspend fun turns…]]></description><link>https://mohammadmd1383.hashnode.dev/reading-a-kotlin-library-s-real-api-from-a-compiled-jar-suspend-nullability-default-args-without-the-java-ified-view</link><guid isPermaLink="true">https://mohammadmd1383.hashnode.dev/reading-a-kotlin-library-s-real-api-from-a-compiled-jar-suspend-nullability-default-args-without-the-java-ified-view</guid><category><![CDATA[Kotlin]]></category><category><![CDATA[Java]]></category><category><![CDATA[jvm]]></category><category><![CDATA[cli]]></category><category><![CDATA[minecraft]]></category><dc:creator><![CDATA[Mohammad Mostafa Dastjerdi]]></dc:creator><pubDate>Mon, 23 Nov 2026 15:16:28 GMT</pubDate><content:encoded><![CDATA[<p>If you've ever run <code>javap</code> on a Kotlin jar, you know the problem: you don't see the Kotlin API, you see what the compiler lowered it to. A <code>suspend fun</code> turns into a method with an extra <code>Continuation</code> parameter that returns <code>Object</code>. Default arguments become <code>foo$default(...)</code> bridge methods with an int bitmask. Properties turn into <code>getX()</code>/<code>setX()</code> pairs. Nullability disappears into annotations, if it's there at all.</p>
<p>That's fine for the JVM, but it's not what you need when you're trying to call the library from Kotlin, or when an AI coding assistant is trying to write code against it.</p>
<h2>Kotlin already ships the answer inside the jar</h2>
<p>Every Kotlin class file carries a <code>@kotlin.Metadata</code> annotation. It encodes the original Kotlin declarations: which functions are <code>suspend</code>, which members are properties, which parameters have defaults, <code>@JvmName</code> renames, and the nullability of every type.</p>
<p><a href="https://mohammadmd1383.github.io/jdx/">jdx</a> is an open-source CLI (and MCP server) that answers IDE-style questions about any JVM jar from the terminal. For Kotlin binaries it reads that <code>@Metadata</code> and renders the Kotlin-true signatures, including nullability, instead of the lowered Java view. It also gives Kotlin-true views for file facades (top-level functions in <code>FooKt</code> classes) and multi-file parts.</p>
<h2>The commands</h2>
<p>List what a type offers, like code completion after <code>.</code> (inherited members are included by default; <code>--declared</code> keeps only the type's own):</p>
<pre><code>jdx members com.example.ApiClient --declared --jars build/libs/client.jar
</code></pre>
<p>See every overload of one member as a single source-style line, with real parameter names, generics and defaults:</p>
<pre><code>jdx signature 'com.example.ApiClient#fetch' --jars build/libs/client.jar
</code></pre>
<p>One dense line per declared member, like an IDE file structure view:</p>
<pre><code>jdx outline com.example.ApiClient --jars build/libs/client.jar
</code></pre>
<p>You can point it at a Maven coordinate instead of a local jar with <code>--coord group:artifact:version</code>. Inside a Gradle or Maven project it finds your dependency jars from the local caches without running Gradle or Maven.</p>
<p>Reference pages: <a href="https://mohammadmd1383.github.io/jdx/docs/reference/members/">jdx members</a> · <a href="https://mohammadmd1383.github.io/jdx/docs/reference/signature/">jdx signature</a> · <a href="https://mohammadmd1383.github.io/jdx/docs/reference/outline/">jdx outline</a></p>
<h2>Kotlin source bodies</h2>
<p>Signatures come straight from bytecode plus <code>@Metadata</code>. If you also want <code>body</code>, <code>source</code> and <code>doc</code> to serve Kotlin sources, run this once:</p>
<pre><code>jdx kotlin install
</code></pre>
<p>It downloads a pinned, SHA-1-verified Kotlin compiler sidecar into jdx's cache. Without it, Kotlin binaries still render through <code>@Metadata</code>; only <code>.kt</code> source queries degrade. Details: <a href="https://mohammadmd1383.github.io/jdx/docs/reference/kotlin/">jdx kotlin</a>.</p>
<p>When there's no sources jar at all, jdx decompiles with Vineflower and labels the output "⚠ reconstructed", so you always know whether you're reading original source or a reconstruction.</p>
<h2>Minecraft modders writing Kotlin</h2>
<p>If you write Fabric mods in Kotlin, or depend on mods that are, the same commands work on a mod jar. Two honest caveats: jdx does not remap, so query the Loom-mapped Minecraft jar by passing it with <code>--jars</code>; and only compare jars that use the same mapping namespace. There's a guide for that workflow: <a href="https://mohammadmd1383.github.io/jdx/docs/minecraft-mods/">inspecting Minecraft mod jars</a>.</p>
<h2>For AI assistants</h2>
<p>This is where the Kotlin-true view matters most. An agent that reads <code>javap</code> output of a Kotlin library will happily try to pass a <code>Continuation</code> or call <code>fetch$default</code>. jdx ships as an MCP server (<code>jdx mcp</code>, 27 typed tools) and one command wires it into Claude Code, Cursor, Codex, Copilot CLI, Cline and others:</p>
<pre><code>jdx setup --agent claude-code --scope project
</code></pre>
<h2>Quick facts</h2>
<ul>
<li>Apache-2.0, written in Kotlin, needs a Java 21+ runtime, Linux/macOS/Windows.</li>
<li>Parses bytecode with ASM; never loads or runs the classes it inspects.</li>
<li>No network unless you ask (<code>--fetch</code>, <code>jdx upgrade</code>, <code>jdx kotlin install</code>).</li>
<li><code>--json</code> on every command, distinct exit codes, and an ambiguous name exits 2 with every candidate listed instead of guessing.</li>
</ul>
<p>Install:</p>
<pre><code>curl -fsSL https://raw.githubusercontent.com/MohammadMD1383/jdx/main/install-release.sh | bash
</code></pre>
<p>Docs: <a href="https://mohammadmd1383.github.io/jdx/">https://mohammadmd1383.github.io/jdx/</a> · Source: <a href="https://github.com/MohammadMD1383/jdx">https://github.com/MohammadMD1383/jdx</a></p>
]]></content:encoded></item><item><title><![CDATA[How to find every implementation of a Java interface inside a JAR (and every ServiceLoader provider)]]></title><description><![CDATA[jdx implementors walks the bytecode type hierarchy; jdx services lists META-INF/services registrations. Together they answer “who implements this?” from…]]></description><link>https://mohammadmd1383.hashnode.dev/how-to-find-every-implementation-of-a-java-interface-inside-a-jar-and-every-serviceloader-provider</link><guid isPermaLink="true">https://mohammadmd1383.hashnode.dev/how-to-find-every-implementation-of-a-java-interface-inside-a-jar-and-every-serviceloader-provider</guid><category><![CDATA[Java]]></category><category><![CDATA[Kotlin]]></category><category><![CDATA[cli]]></category><category><![CDATA[open source]]></category><category><![CDATA[SPI]]></category><dc:creator><![CDATA[Mohammad Mostafa Dastjerdi]]></dc:creator><pubDate>Sun, 22 Nov 2026 10:53:46 GMT</pubDate><content:encoded><![CDATA[<p>When I need to know who implements an interface, I usually do not have an IDE index of the jar. The usual workaround is unzip, run <code>javap</code> on every class, and grep for <code>implements</code>. That misses anonymous classes, it is slow on a folder of dependencies, and it still does not tell you which jars registered a ServiceLoader provider under <code>META-INF/services</code>.</p>
<p>I built <a href="https://mohammadmd1383.github.io/jdx/">jdx</a> to answer that kind of question directly from the terminal. It is an open-source Kotlin CLI and MCP server (v1.7.0, Java 21+, Apache-2.0) that reads JVM bytecode with ASM and never loads or runs the classes it inspects. Two commands cover this job: <code>jdx implementors</code> and <code>jdx services</code>.</p>
<h2>Who implements this interface?</h2>
<p><code>jdx implementors</code> is a thin alias for <code>hierarchy --down</code>. It scans every class in the jars you give it (plus the running JDK, unless you pass <code>--no-jdk</code>) and lists subtypes. <code>--direct</code> keeps the list to types that implement or extend the target themselves; <code>--depth N</code> caps how far a transitive tree can go; <code>--limit</code> caps the printed rows (default 50) and leaves a footer for the rest.</p>
<p>This is the output against Gson 2.14.0, fetched from Maven Central with <code>--coord</code> and <code>--fetch</code>:</p>
<pre><code class="language-console">$ jdx implementors com.google.gson.TypeAdapterFactory --direct --limit 10 --coord com.google.code.gson:gson:2.14.0 --fetch
hierarchy of 'com.google.gson.TypeAdapterFactory'
  subtypes in workspace (10)
    class com.google.gson.internal.Excluder  gson-2.14.0.jar
    class com.google.gson.internal.bind.ArrayTypeAdapter$1  gson-2.14.0.jar
    class com.google.gson.internal.bind.CollectionTypeAdapterFactory  gson-2.14.0.jar
    class com.google.gson.internal.bind.DefaultDateTypeAdapter$1  gson-2.14.0.jar
    class com.google.gson.internal.bind.EnumTypeAdapter$1  gson-2.14.0.jar
    class com.google.gson.internal.bind.JavaTimeTypeAdapters$14  gson-2.14.0.jar
    class com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory  gson-2.14.0.jar
    class com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory$DummyTypeAdapterFactory  gson-2.14.0.jar
    class com.google.gson.internal.bind.MapTypeAdapterFactory  gson-2.14.0.jar
    class com.google.gson.internal.bind.NumberTypeAdapter$1  gson-2.14.0.jar
10 of 21 subtypes shown (--limit 21 to see more)
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)
</code></pre>
<p>The header still says <code>hierarchy of …</code> because implementors reuses that renderer. Names like <code>ArrayTypeAdapter$1</code> are the anonymous factories actually stored in the jar — the ones <code>javap</code> on a handful of public classes would miss. The warning is real too: Gson is a multi-release jar, and jdx tells you it is serving the Java 21 variants.</p>
<p>If you also want the view upward, use <code>jdx hierarchy</code>. With neither <code>--up</code> nor <code>--down</code>, it shows both directions. On <code>JsonElement</code> that is the expected tree: <code>Object</code> above, the four concrete JSON types below.</p>
<pre><code class="language-console">$ jdx hierarchy com.google.gson.JsonElement --coord com.google.code.gson:gson:2.14.0 --fetch
hierarchy of 'com.google.gson.JsonElement'
  supertypes
    extends java.lang.Object  java.base
  subtypes in workspace (4)
    class com.google.gson.JsonArray  gson-2.14.0.jar
    class com.google.gson.JsonNull  gson-2.14.0.jar
    class com.google.gson.JsonObject  gson-2.14.0.jar
    class com.google.gson.JsonPrimitive  gson-2.14.0.jar
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)
</code></pre>
<p><code>--in</code> and <code>--exclude</code> take a glob against the artifact label (jar file name, JDK module, or class-directory name), so you can ask the same question across a whole folder and keep only one jar in the downward list.</p>
<h2>ServiceLoader is a different question</h2>
<p>Implementors reads bytecode. It will find a class that implements an interface even if nothing ever registered it with <code>ServiceLoader</code>. The opposite is also true: a provider listed under <code>META-INF/services</code> can be discovered without walking every class file.</p>
<p>Gson is a clean illustration. Those 21 direct <code>TypeAdapterFactory</code> implementations are not SPI providers. <code>jdx services --coord com.google.code.gson:gson:2.14.0 --fetch --no-jdk</code> exits 1 with <code>no services found</code>. If you only grepped <code>META-INF/services</code>, you would conclude the jar had no factories at all.</p>
<p>JDBC is the other side of that coin. Point <code>jdx services</code> at a couple of drivers and it reads the service files, not the class hierarchy:</p>
<pre><code class="language-console">$ jdx services java.sql.Driver --coord org.postgresql:postgresql:42.7.4 --coord com.h2database:h2:2.3.232 --fetch --no-jdk
services matching 'java.sql.Driver'
h2-2.3.232.jar (1)
  service java.sql.Driver
    provider org.h2.Driver
postgresql-42.7.4.jar (1)
  service java.sql.Driver
    provider org.postgresql.Driver
</code></pre>
<p>Omit the pattern to list every registration in the jars. Matching is a substring against the service interface FQN or the provider class FQN; add <code>--regex</code> or <code>--ignore-case</code> when you need them. It exits 1 when nothing matches, so it is safe to use in a script. <code>--json</code> is available on both commands if you would rather parse a machine-readable envelope.</p>
<p>Two limits are worth knowing up front.</p>
<p><code>jdx services</code> only reads <code>META-INF/services</code>. It does not look at <code>module-info</code> <code>provides</code> — that is <code>jdx modules</code>. And <code>implementors</code> has to resolve the interface type before it can search for subtypes. If the interface comes from the JDK and you passed <code>--no-jdk</code>, you get a lookup failure, not an empty list:</p>
<pre><code class="language-console">$ jdx implementors java.sql.Driver --coord org.postgresql:postgresql:42.7.4 --no-jdk
not found: java.sql.Driver
did you mean:
  org.postgresql.Driver
</code></pre>
<p>Leave the JDK in (the default) and the same query finds the bytecode implementors, which in this case agree with the SPI registrations:</p>
<pre><code class="language-console">$ jdx implementors java.sql.Driver --coord org.postgresql:postgresql:42.7.4 --coord com.h2database:h2:2.3.232 --fetch
hierarchy of 'java.sql.Driver'
  subtypes in workspace (2)
    class org.h2.Driver  h2-2.3.232.jar
    class org.postgresql.Driver  postgresql-42.7.4.jar
warning MULTI_RELEASE_VARIANT: multi-release h2-2.3.232.jar serves version-specific variants for this JDK (21)
</code></pre>
<p>That is why I run both. <code>services</code> answers “what did this jar advertise?” even when the interface is not on the classpath. <code>implementors</code> answers “what actually implements it?”, including types that were never registered.</p>
<h2>A folder of jars, including mods</h2>
<p>The same flags work on files you already have. <code>--jars</code> accepts jar files, class directories, or globs, and is repeatable. Quote the glob so your shell does not expand it:</p>
<pre><code class="language-console">$ jdx implementors java.sql.Driver --jars 'lib/*.jar'
$ jdx services java.sql.Driver --jars 'lib/*.jar' --no-jdk
</code></pre>
<p>Minecraft modpacks are the case I get asked about most. Point <code>--jars</code> at <code>mods/*.jar</code> and ask for a Fabric or mod API interface. An honest caveat: jdx does not remap. The type names it prints are whatever the jar actually stores — intermediary, Yarn, Mojmap, or obfuscated. In your own dev environment, pass the mapped jar that Fabric Loom or ModDevGradle already produced, with <code>--jars</code>.</p>
<p>Once you have a class name, the rest of jdx will read it. <code>jdx show org.postgresql.Driver</code> prints the class card (kind, supertypes, member counts, provenance). From there you can list members or decompile a single method with Vineflower, still without running anything in the jar.</p>
<h2>For AI coding agents</h2>
<p>The same queries are MCP tools (<code>jdx_implementors</code>, <code>jdx_hierarchy</code>, <code>jdx_services</code>) on jdx’s stdio MCP server, so an agent can ask “who implements this?” against your dependency jars instead of unpacking them into the context window. One command wires that up for Claude Code, Cursor, Codex, and the other supported agents:</p>
<pre><code class="language-console">$ jdx setup --agent claude-code --scope project
</code></pre>
<h2>Try it</h2>
<p>Install (Java 21+, Linux, macOS, Windows): <a href="https://mohammadmd1383.github.io/jdx/docs/installation/">installation</a></p>
<ul>
<li><a href="https://mohammadmd1383.github.io/jdx/docs/reference/implementors/">jdx implementors</a></li>
<li><a href="https://mohammadmd1383.github.io/jdx/docs/reference/hierarchy/">jdx hierarchy</a></li>
<li><a href="https://mohammadmd1383.github.io/jdx/docs/reference/services/">jdx services</a></li>
<li><a href="https://mohammadmd1383.github.io/jdx/docs/reference/modules/">jdx modules</a> (for JPMS <code>provides</code>, which <code>services</code> does not read)</li>
<li><a href="https://mohammadmd1383.github.io/jdx/docs/minecraft-mods/">Minecraft mods guide</a></li>
<li>Source: <a href="https://github.com/MohammadMD1383/jdx">github.com/MohammadMD1383/jdx</a></li>
</ul>
]]></content:encoded></item></channel></rss>