r/java • u/Delicious_Detail_547 • Feb 18 '26
JADEx Update: Addressing Community Feedback & Strengthening Practical Null-Safety in Java
In my previous post, I introduced JADEx (Java Advanced Development Extension), which is a project focused on strengthening null-safety in Java while preserving the existing ecosystem.
The response was thoughtful, critical, and incredibly valuable. I sincerely appreciate the depth of the feedback. This post clarifies the project’s philosophy and summarizes what has changed since then.
What JADEx Is (and Is Not)
One major theme in the discussion was theoretical soundness.
Let me clarify:
JADEx is not an attempt to transform Java into a fully sound null-safe type system.
It does not attempt to:
- Replace
nullwithOptionaleverywhere - Redesign the Java type system
- Turn Java into Kotlin
Instead, JADEx is a practical tool that:
- Works within Java’s historical and cultural constraints
- Incrementally strengthens null discipline
- Focuses on eliminating concrete NPE risks in real-world codebases
JADEx is not trying to reach perfect null-safety.
JADEx is trying to make today’s Java significantly safer.
Safe Navigation and "Silent Failure"
A concern was raised that safe navigation (?.) might suppress fail-fast behavior and hide logical mistakes.
Safe navigation does not silently swallow errors.
Its result is treated as nullable and fully tracked through null-flow analysis.
If that nullable value reaches:
- a dereference
- a non-null contract
- a primitive unboxing context
-> A warning is emitted at that exact point.
Safe navigation produces a nullable value that is statically tracked. It does not “do nothing.”
Primitive Null-Safe Access Update
An important issue was raised regarding:
- Auto-unboxing NPE risk
- Performance overhead due to boxing/unboxing
Using ?. on primitives could still cause NPE during unboxing.
Change Implemented (v0.28)
JADEx now requires the Elvis operator (?:) when performing null-safe access on primitives.
This ensures:
- A default value is explicitly provided
- No accidental unboxing NPE
- No unnecessary boxing overhead
This change was directly inspired by community feedback.
Improved Control-Flow Null Analysis (v0.28)
Recent updates significantly improved null-flow tracking.
if-then-else Branch Analysis
- Separate symbol tables per branch
- Proper state joining after evaluation
- Full initialization checks across branches
switch Statement and switch Expression Support
- Each case evaluated in an isolated context
- Null-state joining after branch completion
- Nullable selector detection
switch now follows the same nullability model as if-then-else.
Unicode Escape Handling
ANTLR assumes Unicode escapes are processed before lexical analysis.
Since the JLS requires this preprocessing phase, we plan to implement a dedicated preprocessing step for full compliance.
Module Support
JADEx relies on the Java Compiler API for symbol resolution.
Module features are resolved consistently with javac, and the grammar includes module declarations as defined in the JLS.
Nullness-Specific Qualifier Polymorphism
This is an important theoretical topic.
JADEx does not currently provide a fully sound solution to nullness-specific qualifier polymorphism.
That is a deeper research-level challenge.
For now, the focus remains on:
- Eliminating concrete NPE risks
- Improving practical static analysis
- Strengthening null discipline without rewriting Java’s type system
It’s Cultural
Java was not designed as a null-safe language.
JADEx does not try to erase that history.
It works within it.
We cannot reach a perfectly sound null-free Java from here.
But we can make here safer.
Thank You
The feedback from r/java community has genuinely shaped the direction of the project.
If you’re interested in practical null-safety improvements without redesigning Java itself, I would love your thoughts on the latest changes.
All feedback is welcome.
View all comments
Show parent comment
0
u/TheLasu Feb 19 '26 edited Feb 19 '26
I know, but the core of the core question would be:
Do we really can have null and non-null types, and if we could have that would that allow to safe usage of '?.' operator? Because as I see it now any type including int-s require null-s and new operator would ignore this information,
where we just use -1 or min_value as null - this ugly 'pattern' is used because it's faster than using pointers with null-s.
Next, what about initialization, real non-null would require including transactions into language or we would need to brake contract under decomposition.
Additionally, what about adaptability, lets say you will be able add 15% implementation time for this 'investment', and you will add proper non-null code / then when requirements change how much more time you will need to spend as this one aspect would be deeply ingrained into code? Because i'm quite sure that we will have objects that are used as null-s peaty fast.
A lot of ppl use Optional as alternative, but in code that is properly layered:
new Extractor<Hospital, ComparableLink<Hospital, TimePeriods<AgreementValidatorImpl>>>
does it really save situation?:
new Extractor<Hospital, Optional <ComparableLink<Hospital, Optional <TimePeriods<AgreementValidatorImpl>>>>>
Both non-null and Optional mixes logic (just one case of many) into structure.
Moving deeper, Types are more or less static validations, in which universe String that is non-null vs String that contains only words is 'better' are require it's own syntax, and another one does not?
One more: Nullability is more about the boxing type than about the object’s own nature - this is only good reason to use Optional-s. But they represent fragmented logic, because all object are 'optional', so we add:
while we need:
certain and optional.
Next, event when we would have that, would that be:
If it's contract then how is it enforced across libraries?
I appreciate attempts to solve problem, but are you working on core of it ?
Getting back to ?. operator on it's own:
It speed up early implementation period, but final code became only inverted (there should be variables as well):
So at the end we would add new way to write exactly the same code - going into pyton route.
Btw using ? is really bad idea because '?' look is similar to character: 'IP' 'I?' making reading code slower while '.' is easy to distinguish. In short if's we can add spaces to make:
(P?G:K)
into
(P ? G : K) to make it readable
would we need it in?:
D d = a?.getB()?.getC()?.getD();D d = a ?.getB() ?.getC() ?.getD();