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.

    • JADExOP
      link
      fedilink
      arrow-up
      2
      ·
      2 days 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.

      • TheTechnician27@lemmy.world
        link
        fedilink
        English
        arrow-up
        2
        arrow-down
        1
        ·
        2 days ago

        I have an excruciatingly hard time believing anyone who maintains a legacy codebase is going to look at a brand-new Java extension and say “Yup, that’s the basket we want to put all our eggs in” – compared to a robust, well-tested adjacent language that has vastly more benefits. If an organization is already extensively changing their legacy codebase to comport with some fledgling Java extension, they may as well just port to Kotlin.

        • JADExOP
          link
          fedilink
          arrow-up
          2
          ·
          1 day 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.

  • TheTechnician27@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 days ago

    OP, your documentation on your GitHub is unreadably sprawling, and despite that, you only have one tiny section addressing Kotlin, the most blatantly obvious answer imaginable to nearly everything you’ve created here (the response reads like it was generated by an LLM, just saying):


    Q: Is JADEx trying to replace Kotlin or Java?

    A: No.

    • Kotlin : a separate JVM language, designed independently
    • JADEx : a Java language extension, enhancing Java with null-safety and type expressiveness

    Key Point:

    JADEx does not aim to replace Java; it simply extends Java, making it safer and more expressive while staying fully compatible with existing Java code.


    This really addresses absolutely nothing about why someone would use JADEx over Kotlin when they’re already willing to use non-default Java. IntelliJ can convert existing Java code to Kotlin code. I agree constant by default is nice, but it’s hard to imagine, weighed against Kotlin’s benefits, that it would get someone to stay on Java (especially some fledgling extension of it) if they really want null safety.

    • JADExOP
      link
      fedilink
      arrow-up
      1
      ·
      1 day 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.

    • JADExOP
      link
      fedilink
      arrow-up
      2
      ·
      2 days 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.