Java articles

Managing different date time formats with DateTimeFormatterBuilder

In one of the homework of my Become a Data Engineer course I'm asking students to normalize a dataset. In the dataset a date time field has different supported formats. When I was analyzing the possible solutions, I found a class I've never met before, the DateTimeFormatterBuilder. And it will be the topic of this post.

Continue Reading β†’

Streams, streams, streams everywhere - JVM side this time

Maybe you didn't like my clickbait title but wanted to test my creativity with it ;) And more seriously, in this post I will cover streams but the ones that you're using in your Scala/Java code rather than the distributed ones provided by Apache Kafka. And I decided to write that because by analyzing a lot of Spark I/O method, I meet streams everywhere and I wanted to shed some light on them.

Continue Reading β†’

Handling multiple I/O from one thread with NIO Selector

That's the next post I wrote after my unsuccessful analysis of Apache Kafka source. When I was reading the part responsible for sending requests to the broker, I found that it was partially managed by a Java package that I've never seen before. And that will be the topic of this post.

Continue Reading β†’

JVM JIT optimizations

Last time I was writing a post about the "whys" of code generation. And I found a lot of points related to JVM JIT optimizations. This time I will show what kind of optimization the JVM is capable of at runtime.

Continue Reading β†’

Use cases of Java ServiceLoader

During my analysis of Apache Spark and Apache Beam projects I've discovered the use of ServiceLoader - a Java's util class used to load other classes dynamically.

Continue Reading β†’

Java Flight Recorder

Java Mission Control (JMC) described in previous post comes with another tool helping to understand what happens in the JVM. This tool is the Java Flight Recorder (JFR).

Continue Reading β†’

Java Mission Control tool

Historically JVisualVM was one of Oracle references to monitor the state of the JVM. However the 7th version of Java brought an alternative called Java Mission Control.

Continue Reading β†’

On-heap vs off-heap storage

Java programmers are often limited in their thoughts to heap management and it's justified. JVM offers the possibility to code without taking care about manual objects allocation and deallocation. But, as JVM-based language programmer, at least for personal knowledge, it's good to know that on heap memory is not the single memory storage solution in JVM applications. The complement memory is off-heap.

Continue Reading β†’

Misleading concurrent keyword

Often we think that if something is from "concurrent" package, it's automatically thread-safe. By definition is true, but the definitions rarely make the applications and through this post we'll see why.

Continue Reading β†’

Manipulate bytecode with Javassist

Javassist is a very useful library to manipulate bytecode in Java. In intuitive way it allows to access class members and change their behaviour - as well in source-code level as in bytecode one.

Continue Reading β†’

LockSupport in Java

During reading Thread documentation I found a class that existence I've ignored until now - LockSupport. Some of its methods influence Thread states, so it was quite natural choice for the topic of next posts.

Continue Reading β†’

Code inlining

JIT is a tool plenty of magic, often considered by programmers as too low level to take them into account. But a lot of this magic stuff has a great influence on coding practices. One of them concerns methods size and is called inlining.

Continue Reading β†’

Thread lifecycle in Java

Simply speaking a thread goes from created to terminated state, passing by the execution phase. However in practice it's not so simple because some other steps can occur during execution

Continue Reading β†’

OS Thread Scheduler and Java Thread

Most of time threads manipulation is limited to programming language. Even if this high abstraction is sufficient, it's also good to know what happens under-the-hood when a new thread is created in any programming language (Java in the case of this post).

Continue Reading β†’

Marking in Java Garbage Collection

Garbage Collection in Java has a lot of advantages over manual deallocation of objects. But sometimes its automatic character makes that some of programmers neglect the aspect of objects lifecycle management.

Continue Reading β†’

JPA : entity graphs

Possibility to specify fetching of child entities is quite nice JPA feature. However, it was limited to either define the fetching as LAZY or EAGER. Fortunately, only prior to JPA 2.1.

Continue Reading β†’

Handling InterruptedException

The risk of InterruptedException appears very often in multi-threading environment. As a declared exception, it must be defined either in method signature or caught in try-catch block. However, it must be done in some correct way.

Continue Reading β†’

How do Java objects are passed - by reference or by value ?

Understanding if given object is passed by value or by reference is important to write efficient programs. Which is the strategy in Java ?

Continue Reading β†’

Select n+1 anti-pattern

As other programming components, data access layer has also its own patterns and anti-patterns. One of the most famous examples of anti-patterns is called select n+1.

Continue Reading β†’

Introduction to JUnit 5

JUnit is an incontestable part of each Java project. Step by step this framework comes closer to its new major version - 5.

Continue Reading β†’