Home » Java » Core Java » Page 3

Core Java

JDK 14 – JEP 361 Switch Expressions out from preview

In my previous post, I wrote about switch expressions and related enhancements released as a preview feature for JDK 12. Subsequently, in JDK 13 there were some changes proposed, like using yield keyword to return value from the switch block and released in preview. In the upcoming JDK 14 release, which will go GA in March next year, these changes ...

Read More »

JDK 14 Rampdown: Build 27

Mark Reinhold’s recent post “JDK 14 is now in Rampdown Phase One” announced that “we are now in Rampdown Phase One” and that “the overall feature set is frozen.” JDK 14 Early Access Build #27 (2019/12/12) is a hefty build. In this post, I summarize some of the changes associated with JDK 14 Early Access Build 27 that are particularly ...

Read More »

Type Safe SQL in Java

Strings, String, Strings No matter if you are using frameworks like JPA, MyBatis or Spring Data JDBC you always end up declaring the SQL statements as a Java String.The problem with this approach is that you have to write tests for every statement to make sure that it is even valid SQL. There is no compile time guarantee that the ...

Read More »

Project loom

WHY LOOM? One of the drivers behind streams in Java 8 was concurrent programming. In your stream pipeline, you specify what you want to have done, and your tasks are automatically distributed onto the available processors: var result = myData .parallelStream() .map(someBusyOperation) .reduce(someAssociativeBinOp) .orElse(someDefault); Parallel streams work great when the data structure is cheap to split into parts and the ...

Read More »

Functional Java by Example | Part 8 – More Pure Functions

This is part 8, the last instalment of the series called “Functional Java by Example”. The example I’m evolving in each part of the series is some kind of “feed handler” which processes documents. In the last instalment we’ve seen some pattern matching, using the Vavr library, and treated failures as data too, e.g. take an alternative path and return ...

Read More »

How to build Graal-enabled JDK8 on CircleCI?

Citation: feature image on the blog can be found on flickr and created by Luca Galli. The image in one of the below sections can be also found on flickr and created by fklv (Obsolete hipster). The GraalVM compiler is a replacement to HotSpot’s server-side JIT compiler widely known as the C2 compiler. It is written in Java with the ...

Read More »

Measuring Time: From Java to Kernel and back

Problem Statement Even the most basic problems become interesting when you dig deep enough. Today, I would like to do a deep dive into measuring time in Java. We will start with the very basics of the Java API and gradually move lower in our stack: through the OpenJDK source code, glibc, all the way down to the Linux kernel. ...

Read More »

A beginner’s guide to Java agents

While Java beginners quickly learn typing public static void main to run their applications, even seasoned developers often do not know about the JVM’s support of two additional entry points to a Java process: the premain and the agentmain methods. Both methods allow so-called Java agents to contribute to an existing Java program while residing in their own jar file ...

Read More »

A Disk-Backed arraylist

It sometimes happens that your list can become too big to fit in memory and you have to do something in order to avoid running out of memory. The proper way to do that is streaming – instead of fitting everything in memory, you should stream data from the source and discard the entries that are already processed. However, there ...

Read More »