Java's missing feature: extension methods

What is an extension method? An extension method is the ability to “add” a method directly to an existing type without creating a new derived type, recompiling, or otherwise modifying the existing type. When calling an extension method, there is no significant difference compared to calling the actual method defined in the type. Why you need extension methods Consider a function that, after fetching a string containing multiple item IDs from Redis (each item ID is separated by an English comma), first de-duplicates the item IDs (and is able to maintain the order of the elements), and then finally concatenates the individual item IDs using English commas.

Java Memory Issues in Cloud Native

Java has been one of the most popular programming languages in the past two decades with its active open source community and well-established ecological advantages. Entering the cloud-native era, the booming cloud-native technology releases cloud computing dividends, drives business to cloud-native transformation, and accelerates the digital transformation of enterprises. However, Java’s cloud-native transformation path faces great challenges, and there are many contradictions between Java’s operation mechanism and cloud-native features. Enterprises are leveraging cloud-native technology for deep cost optimization, and resource cost management has been raised to an unprecedented level.

Detailed explanation of JAVA thread problem diagnosis tool Thread Dump

Thread Dump is a very useful tool for diagnosing problems with Java applications. Every Java virtual machine has the ability to generate a thread-dump of the state of all threads at a given point in time. Although the thread dump printed by each Java virtual machine varies slightly, most of them provide a snapshot of the currently active thread and a stack trace of all Java threads in the JVM. The stack information usually contains the full class name and the methods executed and, if possible, the source code line number.

Found a bug in MapStruct expressions

Preface MapStruct is a code generator that greatly simplifies the implementation of mappings between Java Bean types based on a conventionally preferred approach to configuration. The generated mapping code uses simple method calls, so it is fast, type-safe and easy to understand. mapStruct’s expression function is designed to deal with the mapping of special object properties, such as the DTO status property into PO status requires further processing, this time you need to use the expression function.

Getting Started with JavaParser: Analyzing Java Code Programmatically

The JavaParser library provides an abstract syntax tree for Java code. The AST structure allows you to use Java code in a simple programmatic way. When using JavaParser, we usually want to perform a series of operations at a time. Usually, we want to operate on the entire project, so given a directory, we will explore all Java files. This class should help to accomplish the following operations. import; public class DirExplorer { public interface FileHandler { void handle(int level, String path, File file); } public interface Filter { boolean interested(int level, String path, File file); } private FileHandler fileHandler; private Filter filter; public DirExplorer(Filter filter, FileHandler fileHandler) { this.

Jenkins Deploying Java Applications to Tomcat Server

For Java programs, Jenkins requires the use of build tools such as maven, ant, etc., with maven being more popular. Here we use maven to implement the deployment of Java applications. Prepare Java code in GitLab Deploy Tomcat and configure it apt-get -y install tomcat9 tomcat9-admin cp -r /usr/share/tomcat9-admin/* /var/lib/tomcat9/webapps/ Open /var/lib/tomcat9/conf/tomcat-users.xml and do the following configuration. Add the following three lines to create users and authorize them. manager-script for remote script execution privileges <role rolename="manager-gui"/> <role rolename="manager-script"/> <user username="tomcat" password="tomcat" roles="manager-gui,manager-script"/> Open /var/lib/tomcat9/webapps/manager/META-INF/context.

Java Containerization Guide

I. System selection About the most basic underlying image, usually most of us have only three choices: Alpine, Debian, CentOS; of these three for the operation and maintenance of the most familiar with the general CentOS, but unfortunately CentOS later no longer exists in a stable version, about its stability has been a mysterious problem; this is a matter of opinion, I Personally, I don’t use it if I can 😆.

Oracle introduces a direct replacement for JDK 8

To deliver Java 17-level performance to traditional Java 8 server workloads, Oracle announced with the Java SE Subscription Enterprise Performance Pack. It is claimed to be a direct replacement for JDK 8 and is now available on MyOracleSupport for All Java SE subscription customers and Oracle Cloud Infrastructure (OCI) users are offered free of charge. “The Enterprise Performance Pack provides JDK 8 users with the major memory management and performance improvements that were brought to Java in the seven years between the release of JDK 8 and JDK 17.

7 New Features of JDK 19

The JDK 19 feature set is currently frozen, and Java 19 is expected to be officially released in September of this year. Take a look at these 7 new frozen features of JDK 19. Record Patterns (Preview) Enhance the Java programming language to deconstruct record values with Record Patterns, which can nest record patterns and type patterns to enable powerful, declarative, and composable forms of data navigation and processing. This is a preview language feature.

New progress in native Wayland support for OpenJDK

OpenJDK/Java has made progress in implementing native “pure” Wayland toolkit integration that does not rely on X.Org/X11 or XWayland to render Java GUI applications. Developer Alexey Ushakov has updated the OpenJDK Wiki this week to outline the latest progress in getting Wayland support for OpenJDK on Linux, a further refinement to the mature X11 support. This new toolkit support continues to be implemented from scratch and is currently being developed through Java’s Wakefield repository and the “pure_wl_toolkit” branch.