JVM articles

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 β†’

Google Guava cache suppliers

Sometimes we need to cache only singular object, without associating it with any key. In this case the use of Guava's LoadingCache is not well adapted. But fortunately, Guava provides another objects to deal with this situation - Suppliers.

Continue Reading β†’

Java instrumentation example

In one of previous articles we discovered the idea of Java agents. We mentioned that instrumentation package can be used to develop them. It's the time to approach this topic deeper.

Continue Reading β†’

Watching files with WatchService

Java introduces more and more event-driven features. One of them is WatchService which allows to handle files-related events.

Continue Reading β†’

Generations in JVM

Generational garbage collection is one of strategies used to automatically remove useless objects from memory. JVM has 2 categories of generations: young and old.

Continue Reading β†’

Java agents - old innovation

Very often the first version of given language influences programming knowledge. When somebody started with Java 6 and has never used Java agent, this feature introduced in Java 5 can appear mysterious.

Continue Reading β†’

Documenting code with Javadoc

Writing a good code includes writing a code well documented. Usually, "well documented" helps programmer to avoid going to see 10 other people before understanding what the code really does.

Continue Reading β†’

TransferQueue

Often consumer-producer applications stores common elements in shared queue. Java offers different types of this data structure and one of them is TransferQueue.

Continue Reading β†’

Completable future

With Java 8 comes a complementary class to classical Future objects. This class not only helps to work with promises but also makes possible to get future results in non-blocking way.

Continue Reading β†’

Java 8 and Streams

So far only Google Guava allowed us to easily process collections. But the arrival of Java 8 brought a serious alternative to this library - streams.

Continue Reading β†’

Atomic package

Atomicity in thread-safe parallel programming is one of crucial points. Thanks to it, any thread participating in the parallel code execution receives the final value, without the risk to get an "intermediate" value modified by another thread.

Continue Reading β†’

How does Spring Framework manage compatibility with different Java versions ?

Java 9 comes quietly to Java ecosystem and Spring Framework already successfully tested the build on early release on the new Java version. If we add to this the backward compatibility between Java 8, 7 and 6, we could ask us the question: How does it succeed that ?

Continue Reading β†’