from justicecoder@programming.dev to programming@programming.dev on 19 Mar 16:34
https://programming.dev/post/47460653
JADEx (Java Advanced Development Extension) is a practical Java safety layer that enhances the safety of your code by providing null-safety and readonly(final-by-default) enforcement. It strengthens Java’s type system without requiring a full rewrite, while fully leveraging existing Java libraries and tools.
As of v0.59, JADEx now ships a Gradle plugin alongside the existing IntelliJ plugin.
What JADEx does
JADEx extends Java at the source level with two core safety mechanisms:
Null-Safety
Type→ non-nullable by defaultType?→ nullable?.→ null-safe access operator?:→ Elvis operator (fallback value)
String? name = repository.findName(id); String upper = name?.toLowerCase() ?: "UNKNOWN";
Compiles to standard Java:
@Nullable String name = repository.findName(id); String upper = SafeAccess.ofNullable(name).map(t0 -> t0.toLowerCase()).orElseGet(() -> "UNKNOWN");
Readonly (Final-by-Default)
- A single
apply readonly;directive makes fields, local variables, and parametersfinalby default - Explicit
mutablemodifier for intentional mutability - Violations reported as standard Java compile-time errors
What’s new in v0.59 - Gradle Plugin
The JADEx Gradle plugin (io.github.nieuwmijnleven.jadex) integrates .jadex compilation into the standard Gradle build lifecycle via a compileJadex task.
plugins {
id 'io.github.nieuwmijnleven.jadex' version '0.59'
}
- Default source directory:
src/main/jadex - Default output directory:
build/generated/sources/jadex/main/java - Optional
jadex {}DSL block for custom configuration - IntelliJ plugin now integrates with the Gradle plugin via the Gradle Tooling API for consistent path resolution between IDE and build pipeline
jadex {
sourceDir = "src/main/jadex"
outputDir = "build/generated/sources/jadex/main/java"
}
Other Improvements
-
IntelliJ Plugin - Gradle Plugin Integration
- The IntelliJ plugin now integrates with the JADEx Gradle plugin via the Gradle Tooling API.
- Source and output directory resolution is now delegated to the Gradle plugin configuration, ensuring consistency between the IDE and the build pipeline.
-
Parser Performance Optimization
- Improved parser speed by optimizing parser rules.
- Reduces analysis latency in the IDE, providing a smoother editing experience for large
.jadexfiles.
Design philosophy
JADEx is not a new language. It does not modify the JVM. It operates purely at the source level and generates standard Java code, meaning it is fully compatible with existing Java libraries, tools, and workflows. The goal is to make null-safety and readonly(final-by-default) enforcement practical and incremental, applicable file by file to existing codebases without a full rewrite.
Links
- GitHub: github.com/nieuwmijnleven/JADEx
- Gradle Plugin Portal: …gradle.org/…/io.github.nieuwmijnleven.jadex
- Tutorial: Making Your Java Code Null-Safe without Rewriting it
- Real-world example: Applying JADEx to a Real Java Project
- Release note for v0.59: github.com/nieuwmijnleven/JADEx/releases/…/v0.59
Feedback and questions welcome.
#programming
threaded - newest