Back to articles
What if Java had Kotlin-style null-safety without migrating your Spring Boot project to Kotlin?

What if Java had Kotlin-style null-safety without migrating your Spring Boot project to Kotlin?

via Dev.toJADEx

I've been building JADEx — a source-to-source compiler that adds two things Java has always been missing: null-safety and final-by-default semantics. No JVM changes, no runtime dependency, just safer Java. The problem If you've worked on a large Spring Boot codebase, you've seen this everywhere: public String getUsername ( User user ) { if ( user == null ) return null ; if ( user . getProfile () == null ) return null ; return user . getProfile (). getUsername (); } The usual options: @NonNull / @Nullable annotations — opt-in, unenforced at the language level Migrate to Kotlin — cost-prohibitive for large, widely-used legacy Java codebases What JADEx does: Null-Safety JADEx introduces .jadex source files. Non-null is the default. Type? is the explicit opt-in for nullable. // UserService.jadex public String ? getUsername ( User ? user ) { return user ?. profile ?. username ; } The ?. operator chains safely. The ?: Elvis operator provides a fallback: String ? name = repository . findName

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles