justicecoder

joined 7 months ago
[–] justicecoder@programming.dev -5 points 2 months ago (1 children)

i didn't create this post in the general programming community.

[–] justicecoder@programming.dev -4 points 2 months ago

This is JADEx post. get out of hier.

[–] justicecoder@programming.dev -4 points 2 months ago (1 children)

This is JADEx post. get out of hier.

[–] justicecoder@programming.dev -5 points 2 months ago (4 children)

This is JADEx post. get out of hier.

[–] justicecoder@programming.dev 6 points 2 months ago

By that logic, every object-oriented language is just Smalltalk diluted with something. Dilution isn't degradation. Sometimes it's just called adoption.

[–] justicecoder@programming.dev 2 points 2 months ago

Thank you! I'll keep working to make JADEx a compelling option for teams in exactly that situation. Your interest and any feedback along the way means a lot.

[–] justicecoder@programming.dev -1 points 2 months ago (2 children)

JADEx will be maintained for as long as I'm alive, so I suppose I'd better try to stick around as long as possible.

Seriously though, I'd love for more people to get involved and contribute to the project. The more contributors it has, the less that concern applies. If JADEx's direction resonates with you, any contribution (whether it's code, money, feedback, or just spreading the word) is genuinely appreciated.

[–] justicecoder@programming.dev 1 points 2 months ago

JADEx is a solution designed to enhance null-safety in Java. Its key advantage is that existing Java developers can gain null-safety and final-by-default semantics without any learning curve. As a result, compared to migrating to Kotlin, JADEx offers a much more cost-effective way to significantly improve the stability of the legacy Java codebases that many companies continue to operate.

 

I've been working on JADEx (Java Advanced Development Extension) which is a safety layer that makes Java safer by adding Null-Safety and Final-by-Default semantics without rewriting Java codes and modifying the JVM.

Quick recap of what JADEx adds to Java:

  • String? nullable type declaration
  • ?. null-safe access operator
  • ?: Elvis operator
  • apply readonly final-by-default mode per file

Today I'm sharing three things that just landed.


1. Lombok support

This was the most requested thing. JADEx now integrates with Lombok via a Delombok pipeline internally. The key motivation: JADEx's nullability checker needs to see Lombok-generated code (getters, builders, constructors) to avoid blind spots. Without Delombok, nullable fields could silently pass through generated methods unchecked.

@Data
@Builder
@Entity
public class User {
    private String name;
    private String? email;      // @Nullable propagated to getter + builder param
    private Address? address;   // @Nullable propagated to getter + builder param
}

After Delombok, JADEx sees and analyzes the generated code:

// Lombok-generated — JADEx propagates @Nullable into these
@Nullable
public String getEmail() { return this.email; }

public UserBuilder email(@Nullable final String email) { ... }
public UserBuilder address(@Nullable final Address address) { ... }

2. Gradle plugin published

The JADEx Gradle plugin is now on Maven Central and the Gradle Plugin Portal.

plugins {
    id 'io.github.nieuwmijnleven.jadex' version '0.628'
}

jadex {
    sourceDir = 'src/main/jadex'
}

That's the only change needed to an existing Spring Boot project. Everything else (compilation, Delombok pipeline, .java generation) is handled automatically.


3. JADEx Spring Boot example project


We highly welcome your feedback on JADEx.

Thank you.

 

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 default
  • Type? → 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 parameters final by default
  • Explicit mutable modifier 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 .jadex files.

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

Feedback and questions welcome.

[–] justicecoder@programming.dev 0 points 2 months ago

The key point about JADEx is that it’s not intended to compete with Kotlin or replace it.

Kotlin is a separate JVM language with its own ecosystem, compiler, and language model. Migrating a large legacy Java codebase to Kotlin is essentially a language migration project. Even though IntelliJ can automatically convert a lot of Java code, in practice teams still need to review the generated code, adapt APIs, update tooling, and spend time validating the behavior of the migrated system.

JADEx tries to address a different scenario: teams that must stay within the Java ecosystem but still want stronger null-safety guarantees.

Rather than introducing a new runtime or replacing the language, JADEx works as a source-level safety layer:

Java source → JADEx analysis & operators → null-safe Java source

The output is still ordinary, human-readable Java that compiles with the standard Java compiler and works with existing Java libraries and tooling.

Because of that, the adoption model is different from Kotlin. Instead of migrating the entire codebase, teams can apply JADEx gradually to specific parts of an existing Java project to strengthen null-safety.

Kotlin is a great choice for many projects, especially for new development. JADEx is mainly aimed at improving safety in large existing Java codebases where a language migration is not practical.

I’ll restructure the README so that the core idea of the project is easier to grasp and expand the Kotlin comparison section in the documentation, since it’s clearly one of the first questions people have when they see the project.

Thank you for your feedback.

[–] justicecoder@programming.dev 1 points 2 months ago

I think there may be a bit of misunderstanding about what JADEx actually is.

JADEx is designed as a Java safety layer, not a new programming language. It behaves more like a tool that sits on top of Java and strengthens null-safety while keeping full compatibility with the existing Java ecosystem.

The workflow is essentially:

Java (input) -> JADEx tool -> null-safe Java (output)

In other words, developers still work within the Java ecosystem, and the final output is standard Java source code that can be compiled with the regular Java compiler.

The key idea is that existing Java code does not need to be rewritten. You can gradually apply JADEx to strengthen null-safety in legacy codebases without migrating the language itself.

Migrating a large legacy codebase to Kotlin, on the other hand, is closer to a language migration project. It typically requires substantial effort: rewriting parts of the codebase, updating tooling, and spending significant time validating and testing the migrated code.

Because of that, the cost and risk profile are very different.

JADEx aims to provide a lower-friction path to improve safety in existing Java systems, especially for teams that must remain in the Java ecosystem.

Kotlin is a great language and an excellent choice for many projects.

In fact, a very reasonable approach could be:

  • strengthen existing legacy Java systems with JADEx
  • write new components in Kotlin if the team prefers it

Those two approaches are not mutually exclusive and they simply solve different problems.

[–] justicecoder@programming.dev 1 points 2 months ago

JADEx enhances Java with null-safety and readonly (final-by-default) semantics without requiring developers to switch languages. Existing Java developers can adopt these safety features with virtually no learning curve.

Compared to migrating to Kotlin, JADEx provides a significantly more cost-effective way to improve the reliability of large legacy Java codebases that many organizations still rely on.

[–] justicecoder@programming.dev 1 points 2 months ago (2 children)

JADEx enhances Java with null-safety and readonly (final-by-default) semantics without requiring developers to switch languages. Existing Java developers can adopt these safety features with virtually no learning curve.

Compared to migrating to Kotlin, JADEx provides a significantly more cost-effective way to improve the reliability of large legacy Java codebases that many organizations still rely on.

 

JADEx (Java Advanced Development Extension) is a safety layer that makes Java safer by adding Null-Safety and Final-by-Default semantics without modifying the JVM.


Null-Safety

NullPointerException (NPE) is one of the most common sources of runtime failures in Java applications.
Although modern Java provides tools such as Optional and static analysis, null-related bugs are still fundamentally a runtime problem in most Java codebases.

JADEx addresses this problem by introducing explicit nullability into the type system and enforcing safe access rules at compile time.

In JADEx:

  • Typenon-nullable by default
  • Type?nullable
  • ?.null-safe access operator
  • ?:Elvis operator (fallback value)

This design ensures that developers must explicitly acknowledge and handle nullable values before accessing them.

For example:

String? name = repository.findName(id);
String upper = name?.toLowerCase() ?: "UNKNOWN";

When compiled by JADEx, this code is translated into standard Java:

JADEx compiles null-safe expressions into standard Java using a small helper API(SafeAccess).

@Nullable String name = repository.findName(id);
String upper = SafeAccess.ofNullable(name).map(t0 -> t0.toLowerCase()).orElseGet(() -> "UNKNOWN");

In this example:

name is explicitly declared as nullable.

The ?. operator safely accesses toLowerCase() only if name is not null.

The ?: operator provides a fallback value if the result is null.

Instead of writing repetitive null-check logic such as:

if (name != null) {
    upper = name.toLowerCase();
} else {
    upper = "UNKNOWN";
}

JADEx allows the same logic to be expressed safely and concisely.

Most importantly, JADEx prevents unsafe operations at compile time. If a nullable variable is accessed without using the null-safe operator, the compiler will report an error.

This approach shifts null-related problems from runtime failures to compile-time feedback, helping developers detect issues earlier and build more reliable software.


Readonly (Final-by-Default)

JADEx also introduces optional readonly semantics through a final-by-default model.

In large Java codebases, accidental reassignment of variables or fields can lead to subtle bugs and make code harder to reason about. While Java provides the final keyword, it must be manually applied everywhere, which often results in inconsistent usage.

JADEx simplifies this by allowing developers to enable readonly mode with a single directive:

apply readonly;

Once enabled:

  • Fields, local variables, and parameters become final by default

  • JADEx automatically applies final where appropriate

  • Reassignment attempts are reported as compile-time errors

Example:

apply readonly;  
  
public class Example {  
    private int count = 0;  
  
    public static void main(String[] args) {  
        var example = new Example();  
        example.count = 10; // compile-time error  
    }  
}

Since count is generated as final, the reassignment results in a standard Java compile-time error.

If mutability is intentionally required, developers can explicitly opt in using the mutable modifier:

private mutable int counter = 0;

This approach encourages safer programming practices while keeping the code flexible when mutation is necessary.

When compiled, JADEx generates standard Java code with final modifiers applied where appropriate, ensuring full compatibility with the existing Java ecosystem.

//apply readonly;

@NullMarked
public class Example {
    private final int count = 0;

    public static void main(final String[] args) {
        final var example = new Example();
        example.count = 10; // compile-time error
    }
}

Summary

JADEx introduces two complementary safety mechanisms:

Null-Safety

  • Non-null by default

  • Explicit nullable types

  • Safe access operators (?., ?:)

  • Compile-time detection of unsafe null usage

Readonly (Final-by-Default)

  • Final by default

  • Explicit opt-in for mutability

  • Automatic final generation

  • Prevention of accidental reassignment

Together, these features strengthen Java’s type system while remaining fully compatible with existing Java libraries, tools, and workflows.

JADEx does not replace Java.
It simply adds a safety layer that makes Java safer while keeping full compatibility with the existing ecosystem.

 

JADEx (Java Advanced Development Extension) is a safety layer that run on top of Java. It currently supports up to Java 25 syntax and extends it with additional Null-Safety and Readonly features.

GitHub: https://github.com/nieuwmijnleven/JADEx


This release focuses on improving JADEx IntelliJ Plugin stability and responsiveness

Key Improvements

  • Lexer Stability Fix

    • Resolved a crash in JADExLexerAdapter caused by discontinuous token offsets.
    • Ensures continuous token start/end offsets, preventing editor and indexing issues in IntelliJ.
  • Improved Code Completion

    • JADExCompletionContributor refactored to provide smoother and more reliable completion suggestions with better IDE integration.
  • Enhanced Reference Resolution

    • JADExPsiReference resolve logic updated for more dependable symbol resolution in the editor.
  • Parser Performance Optimization

    • Internal trigger logic related to executing the JADEx Processor has been optimized to reduce latency and speed up code editing.

Impact

  • Safer and more stable editing: Files can now be opened and indexed without lexer crashes.
  • Faster and more responsive IDE experience: Code completion and parsing are more efficient.
  • Reliable symbol resolution: References resolve correctly even in complex JADEx codebases.

The IntelliJ Plugin for JADEx v0.49 is now available on the JetBrains Marketplace.

We highly welcome your feedback on JADEx.

Thank you.

 

In the previous post, JADEx introduced a new feature ~~Immutability~~.
Through community feedback, several confusions and limitations were identified.

In v0.42, we have addressed these issues and improved the feature. This post explains the key improvements and new additions in this release.


Improvements

~~apply immutability~~ -> apply readonly

  • The previous term (Immutability) caused misunderstandings.
  • Community feedback revealed that “Immutable” was interpreted differently by different developers, either as Deeply Immutable or Shallowly Immutable.
  • In v0.42, we replaced it with readonly.
  • Meaning: clearly indicates final by default, preventing reassignment of variables.

Expanded Scope of final keyword: now includes method parameters

  • v0.41: final was applied only to fields + local variables
  • v0.42: final is applied to fields + local variables + method parameters
  • Method parameters are now readonly by default, preventing accidental reassignment inside methods.

Example Code

JADEx Source Code

package jadex.example;

apply readonly;

public class Readonly {

    private int capacity = 2; // readonly
    private String? msg = "readonly"; // readonly

    private int uninitializedCapacity; // error (uninitialized readonly)
    private String uninitializedMsg;    // error (uninitialized readonly)

    private mutable String? mutableMsg = "mutable";  // mutable

    public static void printMessages(String? mutableParam, String? readonlyParam) {

        mutableParam = "try to change"; // error
        readonlyParam = "try to change"; // error

        System.out.println("mutableParam: " + mutableParam);
        System.out.println("readonlyParam: " + readonlyParam);
    }

    public static void main(String[] args) {
        var readonly = new Readonly();
        String? mutableMsg = "changed mutable";

        readonly.capacity = 10; // error
        readonly.msg = "new readonly"; // error

        readonly.mutableMsg = mutableMsg;

        printMessages(readonly.msg, mutableMsg);

        System.out.println("mutableMsg: " + readonly.mutableMsg);
        System.out.println("capacity: " + readonly.capacity);
        System.out.println("msg: " + readonly.msg);
    }
}

Generated Java Code

package jadex.example;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import jadex.runtime.SafeAccess;

//apply readonly;

@NullMarked
public class Readonly {

    private final int capacity = 2; // readonly
    private final @Nullable String msg = "readonly"; // readonly

    private final int uninitializedCapacity; // error (uninitilaized readonly)
    private final String uninitializedMsg; // error (uninitilaized readonly)

    private @Nullable String mutableMsg = "mutable";  // mutable

    public static void printMessages(final @Nullable String mutableParam, final @Nullable String readonlyParam) {

        mutableParam = "try to change"; //error
        readonlyParam = "try to change"; //error

        System.out.println("mutableParam: " + mutableParam);
        System.out.println("readonlyParam: " + readonlyParam);
    }

    public static void main(final String[] args) {
        final var readonly = new Readonly();
        final @Nullable String mutableMsg = "changed mutable";

        readonly.capacity = 10; //error
        readonly.msg = "new readonly"; //error

        readonly.mutableMsg = mutableMsg;

        printMessages(readonly.msg, mutableMsg);

        System.out.println("mutableMsg: " + readonly.mutableMsg);
        System.out.println("capacity: " + readonly.capacity);
        System.out.println("msg: " + readonly.msg);
    }
}

New Additions

JSpecify @NullMarked Annotation Support

  • All Java code generated by JADEx now includes the @NullMarked annotation.
  • This improves Null-Safety along with readonly enforcement.

This feature is available starting from JADEx v0.42. Since the IntelliJ Plugin for JADEx v0.42 has not yet been published on the JetBrains Marketplace, if you wish to try it, please download the JADEx IntelliJ Plugin from the link below and install it manually.

JADEx v0.42 IntelliJ Plugin

We highly welcome your feedback on JADEx.

Thank you.

 

In the previous post, JADEx introduced a new feature ~~Immutability~~.
Through community feedback, several confusions and limitations were identified.

In v0.42, we have addressed these issues and improved the feature. This post explains the key improvements and new additions in this release.


Improvements

~~apply immutability~~ -> apply readonly

  • The previous term (Immutability) caused misunderstandings.
  • Community feedback revealed that “Immutable” was interpreted differently by different developers, either as Deeply Immutable or Shallowly Immutable.
  • In v0.42, we replaced it with readonly.
  • Meaning: clearly indicates final by default, preventing reassignment of variables.

Expanded Scope of final keyword: now includes method parameters

  • v0.41: final was applied only to fields + local variables
  • v0.42: final is applied to fields + local variables + method parameters
  • Method parameters are now readonly by default, preventing accidental reassignment inside methods.

Example Code

JADEx Source Code

package jadex.example;

apply readonly;

public class Readonly {

    private int capacity = 2; // readonly
    private String? msg = "readonly"; // readonly

    private int uninitializedCapacity; // error (uninitialized readonly)
    private String uninitializedMsg;    // error (uninitialized readonly)

    private mutable String? mutableMsg = "mutable";  // mutable

    public static void printMessages(String? mutableParam, String? readonlyParam) {

        mutableParam = "try to change"; // error
        readonlyParam = "try to change"; // error

        System.out.println("mutableParam: " + mutableParam);
        System.out.println("readonlyParam: " + readonlyParam);
    }

    public static void main(String[] args) {
        var readonly = new Readonly();
        String? mutableMsg = "changed mutable";

        readonly.capacity = 10; // error
        readonly.msg = "new readonly"; // error

        readonly.mutableMsg = mutableMsg;

        printMessages(readonly.msg, mutableMsg);

        System.out.println("mutableMsg: " + readonly.mutableMsg);
        System.out.println("capacity: " + readonly.capacity);
        System.out.println("msg: " + readonly.msg);
    }
}

Generated Java Code

package jadex.example;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import jadex.runtime.SafeAccess;

//apply readonly;

@NullMarked
public class Readonly {

    private final int capacity = 2; // readonly
    private final @Nullable String msg = "readonly"; // readonly

    private final int uninitializedCapacity; // error (uninitilaized readonly)
    private final String uninitializedMsg; // error (uninitilaized readonly)

    private @Nullable String mutableMsg = "mutable";  // mutable

    public static void printMessages(final @Nullable String mutableParam, final @Nullable String readonlyParam) {

        mutableParam = "try to change"; //error
        readonlyParam = "try to change"; //error

        System.out.println("mutableParam: " + mutableParam);
        System.out.println("readonlyParam: " + readonlyParam);
    }

    public static void main(final String[] args) {
        final var readonly = new Readonly();
        final @Nullable String mutableMsg = "changed mutable";

        readonly.capacity = 10; //error
        readonly.msg = "new readonly"; //error

        readonly.mutableMsg = mutableMsg;

        printMessages(readonly.msg, mutableMsg);

        System.out.println("mutableMsg: " + readonly.mutableMsg);
        System.out.println("capacity: " + readonly.capacity);
        System.out.println("msg: " + readonly.msg);
    }
}

New Additions

JSpecify @NullMarked Annotation Support

  • All Java code generated by JADEx now includes the @NullMarked annotation.
  • This improves Null-Safety along with readonly enforcement.

This feature is available starting from JADEx v0.42. Since the IntelliJ Plugin for JADEx v0.42 has not yet been published on the JetBrains Marketplace, if you wish to try it, please download the JADEx IntelliJ Plugin from the link below and install it manually.

JADEx v0.42 IntelliJ Plugin

We highly welcome your feedback on JADEx.

Thank you.

 

JADEx (Java Advanced Development Extension) is a safety layer that runs on top of Java.
It currently supports up to Java 25 syntax and extends it with additional Null-Safety and Immutability features.

In the previous article, I introduced the Null-Safety features.
For more details, please refer to:


Introducing the New Immutability Feature

If Null-Safety eliminates runtime crashes caused by null,
Immutability reduces bugs caused by unintended state changes.

With v0.41 release, JADEx introduces Immutable by Default Mode


Core Concepts

The Immutability feature revolves around two simple additions:

apply immutability;
mutable

apply immutability;

  • When you declare this at the top of your source file:

    • All fields
    • All local variables (excluding method parameters)
    • are treated as immutable by default.
  • When the JADEx compiler generates Java code:

    • They are automatically declared as final.

mutable keyword

  • Only variables declared with mutable remain changeable.
  • Everything else (excluding method parameters) is immutable by default.

JADEx Source Code


package jadex.example;

apply immutability;

public class Immutability {

    private int capacity = 2; // immutable
    private String msg = "immutable"; // immutable

    private int uninitializedCapacity; // uninitialaized immutable
    private String uninitializedMsg; // uninitialaized immutable

    private mutable String mutableMsg = "mutable";  // mutable

    public static void main(String[] args) {
        var immutable = new Immutability();

         immutable.capacity = 10; //error
         immutable.msg = "new immutable"; //error

         immutable.mutableMsg = "changed mutable";

        System.out.println("mutableMsg: " + immutable.mutableMsg);
        System.out.println("capacity: " + immutable.capacity);
        System.out.println("msg: " + immutable.msg);
    }
}

Generated Java Code

package jadex.example;

//apply immutability;

public class Immutability {

    private final int capacity = 2; // immutable
    private final String msg = "immutable"; // immutable

    private final int uninitializedCapacity; // uninitialaized immutable
    private final String uninitializedMsg; // uninitialaized immutable

    private String mutableMsg = "mutable";  // mutable

    public static void main(String[] args) {
        final var immutable = new Immutability();

         immutable.capacity = 10; //error
         immutable.msg = "new immutable"; //error

         immutable.mutableMsg = "changed mutable";

        System.out.println("mutableMsg: " + immutable.mutableMsg);
        System.out.println("capacity: " + immutable.capacity);
        System.out.println("msg: " + immutable.msg);
    }
}

This feature is available starting from JADEx v0.41. Since the IntelliJ Plugin for JADEx v0.41 has not yet been published on the JetBrains Marketplace, if you wish to try it, please download the JADEx IntelliJ Plugin from the link below and install it manually.

JADEx v0.41 IntelliJ Plugin

We highly welcome your feedback on the newly added Immutability feature.

Finally, your support is a great help in keeping this project alive and thriving.

Thank you.

 

JADEx (Java Advanced Development Extension) is a safety layer that runs on top of Java.
It currently supports up to Java 25 syntax and extends it with additional Null-Safety and Immutability features.

In the previous article, I introduced the Null-Safety features.
For more details, please refer to:


Introducing the New Immutability Feature

If Null-Safety eliminates runtime crashes caused by null,
Immutability reduces bugs caused by unintended state changes.

With v0.41 release, JADEx introduces Immutable by Default Mode


Core Concepts

The Immutability feature revolves around two simple additions:

apply immutability;
mutable

apply immutability;

  • When you declare this at the top of your source file:

    • All fields
    • All local variables (excluding method parameters)
    • are treated as immutable by default.
  • When the JADEx compiler generates Java code:

    • They are automatically declared as final.

mutable keyword

  • Only variables declared with mutable remain changeable.
  • Everything else (excluding method parameters) is immutable by default.

JADEx Source Code


package jadex.example;

apply immutability;

public class Immutability {

    private int capacity = 2; // immutable
    private String msg = "immutable"; // immutable

    private int uninitializedCapacity; // uninitialaized immutable
    private String uninitializedMsg; // uninitialaized immutable

    private mutable String mutableMsg = "mutable";  // mutable

    public static void main(String[] args) {
        var immutable = new Immutability();

         immutable.capacity = 10; //error
         immutable.msg = "new immutable"; //error

         immutable.mutableMsg = "changed mutable";

        System.out.println("mutableMsg: " + immutable.mutableMsg);
        System.out.println("capacity: " + immutable.capacity);
        System.out.println("msg: " + immutable.msg);
    }
}

Generated Java Code

package jadex.example;

//apply immutability;

public class Immutability {

    private final int capacity = 2; // immutable
    private final String msg = "immutable"; // immutable

    private final int uninitializedCapacity; // uninitialaized immutable
    private final String uninitializedMsg; // uninitialaized immutable

    private String mutableMsg = "mutable";  // mutable

    public static void main(String[] args) {
        final var immutable = new Immutability();

         immutable.capacity = 10; //error
         immutable.msg = "new immutable"; //error

         immutable.mutableMsg = "changed mutable";

        System.out.println("mutableMsg: " + immutable.mutableMsg);
        System.out.println("capacity: " + immutable.capacity);
        System.out.println("msg: " + immutable.msg);
    }
}

This feature is available starting from JADEx v0.41. Since the IntelliJ Plugin for JADEx v0.41 has not yet been published on the JetBrains Marketplace, if you wish to try it, please download the JADEx IntelliJ Plugin from the link below and install it manually.

JADEx v0.41 IntelliJ Plugin

We highly welcome your feedback on the newly added Immutability feature.

Finally, your support is a great help in keeping this project alive and thriving.

Thank you.

 

JPlus is a modern programming language and compiler that acts as a superset of Java — bringing the benefits of null safety and powerful boilderplate code generation declarative features while remaining fully interoperable with existing Java code and libraries.

view more: next ›