Home » Java (page 30)


Java: Streaming a JDBC ResultSet as JSON

This post shows how you can convert a java.sql.ResultSet to JSON and stream it back to the caller. This is useful if you want to send a large dataset from a JDBC DataSource to a web application in JSON format. Streaming allows you to transfer the data, little by little, without having to load it all into the server’s memory. ...

Read More »

ActiveMQ Performance Testing


We use ActiveMQ as our messaging layer – sending large volumes of messages with a need for low-latency. Generally it works fine, however in some situations we’ve seen performance problems. After spending too much time testing our infrastructure I think I’ve learned something interesting about ActiveMQ: it can be really quite slow. Although in general messages travel over ActiveMQ without ...

Read More »

JDK 12 News (13 September 2018)

With General Availability of JDK 11 planned for later this month (25 September 2018), it’s a good time to start looking more closely at JDK 12. In a message titled “Proposed schedule for JDK 12” on the OpenJDK jdk-dev mailing list, Mark Reinhold announced, “With JDK 11 nearly out the door, here’s a proposed schedule for JDK 12.” The schedule ...

Read More »

Thread-local state availability in reactive services

Any architecture decision involves a trade-off. It’s no different if you decide to go reactive, e.g. on one side using Reactive Streams implementations gives better resources utilization almost out of the box but on the other hand makes debugging harder. Introducing reactive libraries also has huge impact on your domain, your domain will no longer speak only in terms of ...

Read More »

Arrays.hashCode(Object[]) versus Objects.hash(Object…)

Since JDK 1.5, the Arrays class has offered overloaded static methods with the name “hashCode“​. Most of the overloaded methods accept an array of a particular primitive type, but the Arrays.hashCode(Object[]) method can be used to calculate an int hash code for an array of reference types. Since its JDK 1.7 inception, the Objects class has provided a method called ...

Read More »

Query Databases Using Java Streams

In this article, you will learn how you can write pure Java applications, that are able to work with data from an existing database, without writing a single line of SQL (or similar languages like HQL) and without spending hours putting everything together. After your application is ready, you will learn how to accelerate latency performance with a factor of ...

Read More »

JEP 342: The JVM and Spectre

JEP 342 (“Limit Speculative Execution”) has transitioned from “Draft” state to “Candidate” state, but it has not yet been targeted to a specific JDK release (see graphic for steps in JEP process). Jesper Wilhelmsson has written that JEP 342 “covers the initial work to make use of new C++ compiler options to limit speculative execution in native code in the ...

Read More »

JDK 12 Switch Expression Encountering Unanticipated Enum Value

As I wrote about in my post “Playing with JDK 12’s Switch Expressions“, the JDK 12 Early Access Builds have made it easy to experiment with the implementation of JEP 325 [“Switch Expressions (Preview)”]. My post “JDK 12: Switch Statements/Expressions in Action” used code examples to demonstrate core features and characteristics of the enhanced switch statement and the new switch ...

Read More »

JDK 12: Switch Statements/Expressions in Action

My last post “Playing with JDK 12’s Switch Expressions” talked about use of the JDK 12 Early Access Builds to try out JEP 325 switch expressions and statements and provided a simple example. This post uses the same JDK 12 Early Access Build 10 to demonstrate different features of switch expressions and enhanced switch statements. I used a 2×2 grid ...

Read More »