One year ago, on
March 18, 2014, Java SE 8 was released, and with it, the bliss of functional programming through
lambda expressions and the streams API. These were great news for all of our Java ecosystem, and many people have already upgraded to Java 8.
Stack Overflow already yields almost 2500 questions about Java 8 (
with Brian Goetz himself answering). Also,
Google Trends shows a massive increase in search volume

But even after one year, neither the javac compiler, nor the three major IDE compilers are fully Java 8 ready yet. This question by user meriton was asked on Stack Overflow, recently:
Lambda type inference infers an exception type not thrown by the lambda
The question shows the following piece of code:
class TestException extends Exception {
}
interface Task<E extends Exception> {
void call() throws E;
}
public class TaskPerformer {
private <E extends Exception> void perform(Task<E> task) throws E {
task.call();
}
public static void main(String[] args) {
// compilation error
new TaskPerformer().perform(() -> {
try {
throw new TestException();
} catch (TestException e) {
return;
}
});
}
}
The false positive compilation error has probably been fixed with issue
429430. In any case, it is not reproducible with
Eclipse 4.5.0 M5, available as a developer build
With Java 8, compiling Java code hasn’t really become any easier than before. The above bug has been produced by a very subtle combination of:
- Checked vs. unchecked exceptions
- Generics (and exceptions)
- Lambda expressions
- Type inference
- Flow analysis
If you’ve ever had a look at compiler source code, you cannot help but be glad that someone else is doing that job for you (the same is true when you look at
jOOQ’s or
Hibernate’s sources, by the way).
Where are we at with our compilers?
We’re getting there. My personal feeling is that early access releases of javac work best. For instance, I’m using
build 1.8.0_40-ea-b23
(disclaimer: this article was written before it was published. many problems are now gone with 1.8.0_40)
… although, you probably don’t want to go to production with such an early access release. IDEs building with javac, and Maven, of course, work equally well. Eclipse is lagging a little bit – which can be annoying at times.
Some of you non-Eclipse users might smirk and get your Eclipse vs. IntelliJ rants ready, and you know… there’s a saying about that:
A vegan, an IntelliJ user, a Mac user, and a Linux user walked into a bar.
How do I know?
AFTER 2 MINUTES, THE WHOLE DARN BAR KNEW!
(
We actually have a whole article on that topic)
The fact is, all of the compiler teams are working hard to fix loads of bugs. IntelliJ, even while using javac to compile, may still display some false positives, visually in your IDE.
Geertjan from NetBeans has just recently fixed a whole pile of bugs that we’ve reported. And Eclipse, well, Eclipse ships with their own very sophisticated incremental Java compiler. It’s a great compiler for rapid prototyping, but the drawback is that it compiles stuff slightly differently from others.
While developing
jOOQ and also
jOOλ, we’ve discovered quite a few bugs in Eclipse – many of them having been fixed already in Eclipse Mars. For instance:
We’re getting there. If you can, make use of lambdas and streams, and apply as much type inference in your code as possible. And please, if you do discover a bug, report it. We’re probably all using one of those three IDEs. Every bug that you report, is one less obstacle towards Java 8 adoption.
Here are the links to start registering bugs:
Like this:
Like Loading...
Published by lukaseder
I made jOOQ
View all posts by lukaseder
<<>>
I think that that should be:
A vegan, an IntelliJ user, a Mac user, a Linux user, and a lambda/streams user walked into a bar.
:-)
Aahahah :) wow is that how it feels in the “real world” software industry? I’ve been away from actual (non-PL/SQL) projects for a while, so my writing about Java/lambda/streams is probably not representative
Just out of curiosity: has anybody recently migrated to Eclipse 4.4.2 and also noticed that many views’ layout gets messed up when switching/resizing views? There’s a bug on Bugzilla (https://bugs.eclipse.org/bugs/show_bug.cgi?id=461573), but so far, it didn’t get too much attention, even though this seems to be a regression introduced in 4.4.2, as I’ve never seen such problems in 4.4.1
Don’t know… Because of the reasons mentioned in this post, I’ve been on Eclipse 4.5 milestones for quite a while…
Eclipse 4.5 milestones are affected, too.
Interesting, I hadn’t noticed so far… Or perhaps, I just accepted the fact :)