Skip to content
morphismxPublic

About

Jabel - unlock Javac 9+ syntax when targeting Java 8

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Jabel - use modern Java 9–25 syntax when targeting Java 8

Because life is too short to wait for your users to upgrade their Java!

Independent fork of bsideup/jabel (Apache 2.0), published under the net.morphismmc namespace.

Highlights

  • Write Java 9–25 syntax, run on Java 8: Compiles modern language features down to strict Java 8 (v52) classfiles.
  • Zero runtime dependencies: No shaded runtime library or agent is needed on your application's classpath.
  • --release 8 API safety: Java 9+ standard library APIs (such as List.of() or String.isBlank()) are still caught at compile time so artifacts remain safe on Java 8.

Requirements

  • Build JDK: JDK 17, 21, or 25
  • Runtime JRE: Java 8 or newer

Supported Syntax

  • Java 9–16: var, switch expressions, text blocks, instanceof pattern matching, private interface methods, records (no @Desugar needed), diamond anonymous classes, effectively final try-with-resources, @SafeVarargs on private methods, local enums / static inner members
  • Java 17: Sealed classes and interfaces
  • Java 21: Pattern matching for switch, record patterns, guarded when clauses
  • Java 22: Unnamed variables and patterns (_)
  • Java 25: Primitive patterns in instanceof / switch, flexible constructor bodies (statements before super(...) / this(...)), compact source files & instance main

See Supported Language Features for the full feature list and module IDs.

Quick Start

Gradle (Recommended)

Add the MorphismMC Maven repository in settings.gradle.kts:

pluginManagement {
    repositories {
        maven("https://repo.morphismmc.net/releases")
        gradlePluginPortal()
    }
}

dependencyResolutionManagement {
    repositories {
        maven("https://repo.morphismmc.net/releases")
        mavenCentral()
    }
}

Apply the Jabel plugin in build.gradle.kts with a JDK 17, 21, or 25 toolchain:

plugins {
    java
    id("net.morphismmc.jabel") version "2.0.0-SNAPSHOT"
}

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(21) // or 17 / 25
    }
}

jabel {
    // Optional configuration — see docs/configuration.md
}

The Gradle plugin automatically enables options.fork, injects the required --add-opens flags, sets options.release = 8, synchronizes IntelliJ IDEA / Eclipse source levels, and wires jabel-javac-plugin.

Maven

Add the MorphismMC Maven repository and register jabel-maven-plugin as an extension (<extensions>true</extensions>):

<pluginRepositories>
    <pluginRepository>
        <id>morphismmc</id>
        <url>https://repo.morphismmc.net/releases</url>
    </pluginRepository>
</pluginRepositories>

<repositories>
    <repository>
        <id>morphismmc</id>
        <url>https://repo.morphismmc.net/releases</url>
    </repository>
</repositories>

<build>
    <plugins>
        <plugin>
            <groupId>net.morphismmc</groupId>
            <artifactId>jabel-maven-plugin</artifactId>
            <version>2.0.0-SNAPSHOT</version>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

For full Gradle/Maven options, manual maven-compiler-plugin configuration, and raw javac / -Xplugin:jabel usage, see the Configuration Reference.

IDE Support

Automatic IDE Synchronization (Gradle)

jabel-gradle-plugin automatically configures IntelliJ IDEA (idea.module / idea.project) and Eclipse (eclipse.jdt, when the eclipse plugin is applied) so your editor uses the toolchain's source language level while keeping target bytecode at Java 8 (1.8). Set jabel { configureIde = false } to opt out.

IntelliJ IDEA API Inspection

When targeting --release 8, the compiler rejects Java 9+ standard library APIs. To get matching editor warnings in IntelliJ IDEA:

  • Open Configure inspections on the language level / API usage inspection
  • Find Usages of API which isn't available at the configured language level
  • Set Higher than to 8 - Lambdas, type annotations etc.

IntelliJ IDEA Language Level Inspection

Documentation

About

Jabel - unlock Javac 9+ syntax when targeting Java 8

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages