Re:Fluent: Static Extension Methods for Java
by rogerkeays on Monday July 03, 2023 @03:48AM
(#36570037)
Kotlin is great, but it is a fairly heavy dependency if all you want is extension methods. Java has mostly caught up in many other aspects, so I'm experimenting with Java + one or two compiler hacks. Checked exceptions are my next target...
[ Parent
| on HN ]
Re:Fluent: Static Extension Methods for Java
by javanonymous on Monday July 03, 2023 @06:48AM
(#36571161)
I'm curious about how you plan to work on checked exceptions.
If it's just about ignoring forced exception management, Lombok provides the @SneakyThrows annotation.
I would need something more before I add a new type of extension. Maybe if you could solve the null-check issue.
i.e. rewriting
var x = a.getFoo()?.getBar()
to var x = a.getFoo() != null ? a.getFoo().getBar() : null
In that case I may consider it for my personal projects, and then potentially recommend it at work once it becomes more widespread and has IDE support.
Re:Fluent: Static Extension Methods for Java
by rogerkeays on Monday July 03, 2023 @09:14AM
(#36572433)
I don't know yet. I'm already using some of my own variations of sneakyThrows, but what I really want is just to disable the whole damn thing in the compiler (checked exceptions are a compiler feature, not a JVM feature). I won't be changing the Java syntax though, sorry!
Re:Fluent: Static Extension Methods for Java
by zeedude on Monday July 03, 2023 @09:57AM
(#36572934)
I believe Manifold already does this.
https://github.com/manifold-systems/manifold/tree/master/man...
Re:Fluent: Static Extension Methods for Java
by rogerkeays on Monday July 03, 2023 @10:27AM
(#36573391)
sweet