Posts Tagged: jvm

How to read version number and other details from Java manifest

Posted by & filed under , .

One of the challenges I have seen teams struggle with nowadays is versioning their packages. One of the problems with adopting any versioning system is that typically you have to version (at least) 2 components: the binary you are releasing AND the source code, at the time you have built the software. Doing this allows […]

The eternal issue about Object.hashCode() in Java

Posted by & filed under , .

Have you heard of hashCode() and equals() in Java and the eternal discussions around this? And you know by now the implications of having a messed up relationship in between hashCode and equals so you make sure every time you implement a class with an equals() you have to make sure hashCode() follows suit right? […]

network pc monitors

Parallel RxJava and Spock Oddity

Posted by & filed under , .

I use RxJava a lot nowadays — back in the day before I joined Netflix I was struggling with it a bit and mostly watched from the sideline but nowadays I find myself pulling in that dependency in a lot of the Java code I’m writing. And I also use the Spock framework a lot […]

network pc monitors

Interesting Java Jersey + RxJava finding

Posted by & filed under , .

It so happens that in a few of the apps I work on here in Netflix we use Jersey libraries inside a Tomcat container. As such I use the JSR annotations a lot safe in the knowledge that Jersey will take care of all the plumbing work and deal with routing and serialization/deserialization so I […]

About composition and delegation in the Groovy language

Posted by & filed under , .

When dealing with OOP languages, composition over inheritance has been the preferred approach for a while now as it offers a greater flexibility in most cases. Before you start, I’m not going to get into that dispute whether one should opt for inheritance or not, enough to say that there are cases where composition is […]

Using Optional in Java to check for null

Posted by & filed under , .

I see the need for null in Java still, but since the Optional class was introduced I think some of the usages of null can be eliminated by employing some of the capabilities of the Optional class. I will explain in this post a nice way you can implement checking for null in Java by […]

Common mistake when dealing with Reader in Java

Posted by & filed under , .

I’ve encountered this one a few times and came across again recently and thought it relevant to deserve its own post, so here it is. If you have done any I/O in Java you likely came across the Reader class, unlike the InputStream class(es) which deal with bytes, the Reader makes the transition into reading […]

Nicer implementations using Java streams

Posted by & filed under , .

I am not entirely sold on the performance of the Java streams but I will accept they are getting much better compared to the first cut, we now have parallel streams and all sorts, and also it provides a (nicer) functional approach to coding. I’m not going to go into the whole dispute of whether […]

java code

Java Dependency Injection and a Useless Annotation

Posted by & filed under , .

I’ve stepped into the Guice territory rather recently — coming from the Spring framework side of things — and I guess I had so far a similar love/hate experience as with Spring. I rely mostly on the javax.annotation standards anyway so to a certain degree whether it’s Spring or Guice I guess doesn’t make that much […]

Scripting

Java, Map and Optional

Posted by & filed under , .

I do like the Optional class in Java — it is a long awaited elegant replacement for returning null whenever something isn’t there then relying on if( x != null ) checks or using ?: in the format (x == null) ? “foo” : “bar”. It works great also with the new Java stream classes […]