Posts Tagged: JDK

On Java Annotations and Type Safety

Posted by & filed under , .

Nicolas Fränkel published a blog entry recently talking about “Type-safe annotations” in Java — which trigger my thoughts on the same matter, and voila, there’s this post as a result of it. This is in fact my 2 cents on the matter — and as such I’d recommend you read Nicolas’ point of view too […]

java code

Java … FunctionalInterface … WTF?

Posted by & filed under , .

If you’ve been doing “stuff” with Java 8 for a while I’m sure you’ve stepped into lambdas territory and the joys of succinct code it allows to be written. And if you are like me you probably found yourself using lambda’s everywhere you are confronted with a single-method interface. Which is allowed. In fact it’s […]

Why You Should Use Default Methods in Java 8 Interfaces

Posted by & filed under , .

With Java 8, Oracle introduced the concept of “default methods” in interfaces (and if you really haven’t heard of this — wtf?? — you can read more here about it: https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html). This argue some is a step towards multiple inheritance and as such should be banished from the oh, so pure! Java language. Others point out […]

Java Map and Subtleties of getOrDefault vs computeIfAbsent

Posted by & filed under , .

I wrote recently about the new niceties in the Map interface that Java 8 brought to light where I’m highlighting in particular 2 new methods: getOrDefault and computeIfAbsent (see my previous post here about it). These provide a cleaner (and as it turns out faster too!) way of retrieving values from a Map instance. However, […]

Java 8 — Map and the Unknown “Niceties”

Posted by & filed under , .

Despite Java 9 making its way into the real world nowadays, I see a lot of Java code out there still relying on the old-style Java 6-like syntax. And I’m not talking about the usage of lambda’s, stream’s and the likes, but rather some of the improvements Java 8 brought to existing classes in the […]

Please Stop Using Thread.sleep() in Java!

Posted by & filed under , , .

Ok, I need a good moan about this to the extent that it deserves its own blog post, but I had it with the bloody Thread.sleep() method in Java! I know it was the only way to “sleep” back in the day but seriously, but seriously, we have TimeUnit since JDK 1.5 — and nowadays […]

JAX London Logo

Of Java Streams … Again!

Posted by & filed under .

I just went again through this JAX London write-up (read more here: http://www.infoq.com/news/2015/10/jax-london-2015-round-up) and thought it was worth some more thoughts from me. As you might recall, I have touched before on the subject of Java 8 streams in this blog post back in Sep/2014. The thing that puzzled me back then was the fact […]

Convenience Factory Methods for Collections in Java 9

Posted by & filed under , .

Looking the other day through the JDK Enhancements Proposals (aka “JEP“) I came across JEP-269: “Convenience Factory Methods for Collections”. Oh hello, where have you been all these previous JDK releases? 🙂 It seems finally the Java world has woken up to what other JVM languages (and not only!) have been offering for a while: […]

Odd Behaviour in Groovy when Comparing Maps

Posted by & filed under , .

I came across this the other day and I ended up spending quite some time on it pulling my hair and I still couldn’t explain it in the end so I thought  I’d post here to see if anyone can shed some light into it. In brief, it’s about Groovy’s (otherwise awesome!) feature of comparing […]

Scripting

Cobertura Issue with Ignoring Annotated Methods

Posted by & filed under , .

I’ve decided to plug in Cobertura in (some) of my projects to have an idea on the unit test/code coverage going on. I use Gradle, so I started looking at the Cobertura Gradle plugin. It turns out it’s pretty good — and offers a lot of the functionality that I needed. However, I came across […]