Use Java Annotation With JUnit 5 Extension

Java annotations are quite useful in many areas such as introspection, Aspect-Oriented Programming, etc. Spring Framework uses quite a lot of annotations. My team has been using annotations extensively in our projects and one particular use case is using annotations together with JUnit 5 ParameterResolver to inject test resources. We will start by creating a custom annotation: @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface FileResource { /** * @return the path to the resource. */ String value(); /** * @return the type of value that should be decoded from the resource */ Class<?> type() default String.class; } Then we would need to…

Continue ReadingUse Java Annotation With JUnit 5 Extension

Java Just-In-Time(JIT) Compiler Overview

The JIT compiler is the heart of the Java Virtual Machine(JVM). It improves the performance of Java applications at runtime. Nothing controls the performance of your application more than the JIT compiler. Nowadays we don't normally need to tune the JIT compiler due to popularity of Microservices framework like Spring Boot, but in my opinion it is still good to know how things work under the hood. The following picture gives an overview of how the JIT compiler fits in Oracle HotSpot JVM. As you can see, Javac compiler compiles Java source code into an intermediate low-level language (Java Bytecode),…

Continue ReadingJava Just-In-Time(JIT) Compiler Overview

Most Useful Java Books And Libraries

Java has been my main language since I started programming more than 10 years ago. It has evolved quite a lot over the past years. There are many nice frameworks built around Java, such as Spring, Play, Akka, etc. This post gives a list of books and libraries in my opinion are very useful and would help Java engineers.

Continue ReadingMost Useful Java Books And Libraries