Home » Tag Archives: Java 8 (page 8)

Tag Archives: Java 8

Java Lambdas and Low Latency

Overview The main question around the use of Lambdas in Java and Low Latency is; Does they produce garbage and is there anything you can do about it? Background I am working on a library which supports different wire protocols. The idea being that you can describe the data you want to write/read and the wire protocol determines if it ...

Read More »

2015 Starts Off Strong for Java 8

JDK 8 is starting 2015 with a surge in popularity in terms of blog posts and articles. This is coinciding with Java being automatically upgraded to JDK 8 this month. In this post, I list and briefly describe some of the numerous articles and posts on JDK 8 that have been published already in 2015. JDK 8 Streams have been ...

Read More »

Java8 Sorting – Performance Pitfall

Java 8 brings all the goodness of lambdas to enable us to program using a declarative style. But is it really free? And should we be concerned about the price we have to pay for the new programming goodies? Here’s an example where we might have to worry. Consider sorting instances of this simple class:           ...

Read More »

Fail-fast validations using Java 8 streams

I’ve lost count of the number of times I’ve seen code which fail-fast validates the state of something, using an approach like:                     public class PersonValidator { public boolean validate(Person person) { boolean valid = person != null; if (valid) valid = person.givenName != null; if (valid) valid = person.familyName != ...

Read More »

Java 8 Stream and Lambda Expressions – Parsing File Example

Recently I wanted to extract certain data from an output log. Here’s part of the log file:                   2015-01-06 11:33:03 b.s.d.task [INFO] Emitting: eVentToRequestsBolt __ack_ack [-6722594615019711369 -1335723027906100557] 2015-01-06 11:33:03 c.s.p.d.PackagesProvider [INFO] ===---> Loaded package com.foo.bar 2015-01-06 11:33:04 b.s.d.executor [INFO] Processing received message source: eventToManageBolt:2, stream: __ack_ack, id: {}, [-6722594615019711369 -1335723027906100557] 2015-01-06 11:33:04 ...

Read More »

Stream-Powered Collections Functionality in JDK 8

This post presents application of JDK 8 – introduced Streams with Collections to more concisely accomplish commonly desired Collections-related functionality. Along the way, several key aspects of using Java Streams will be demonstrated and briefly explained. Note that although JDK 8 Streams provide potential performance benefits via parallelization support, that is not the focus of this post. The Sample Collection ...

Read More »

How To Process Java Annotations

One of the cool new features of Java 8 is the support for lambda expressions. Lambda expressions lean heavily on the FunctionalInterface annotation. In this post, we’ll look at annotations and how to process them so you can implement your own cool features. Annotations Annotations were added in Java 5. The Java language comes with some predefined annotations, but you ...

Read More »

Testing JVM server-side JavaScript with Jasmine, Spock and Nashorn

JavaScript usage is not limited to client-side code in browser or NodeJS powered server-side code. Many JVM based projects are using it as internal scripting language. Testing this sort of functionality is neither straightforward nor standard. In this post I intend to demonstrate an approach for testing JavaScript in server-side JVM environment using mature tools like Jasmine, Spock and Nashorn. ...

Read More »

Java 8 StringJoiner

At the release of Java 8 the most attention went to the Lamda’s, the new Date API and the Nashorn Javascript engine. In the shade of these, there are smaller but also interesting changes. Amongst them is the introduction of a StringJoiner. The StringJoiner is a utility to delimit a list of characters or strings. You may recognize the code below: ...

Read More »

Really Too Bad that Java 8 Doesn’t Have Iterable.stream()

This is one of the more interesting recent Stack Overflow questions: Why does Iterable not provide stream() and parallelStream() methods? At first, it might seem intuitive to make it straight-forward to convert an Iterable into a Stream, because the two are really more or less the same thing for 90% of all use-cases. Granted, the expert group had a strong ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns