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. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 import java.

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 1 2 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. 1 2 3 4 Add the following three lines to create users and authorize them.

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.

Making Java Agent work better on Dragonwell

Background Java Agent technology can dynamically modify Java application behavior without reworking the code. It is because of these features that many middleware teams, cloud vendor teams, and open source products, started using Java Agent technology to provide some basic capabilities, such as Apache Skywalking, OpenTelemetry all provide Java Agent. Earlier, middleware teams provided capabilities through SDKs (e.g., observable, microservice governance capabilities, etc.); however, each time middleware teams added new features and fixed defects, they needed each business party to update the SDK version and re-release it.

Introduction to the new features of Java 19

Java 19 Officially released on September 20, 2022, Java 19 is not a long term support release until March 2023 when it will be replaced by JDK 20, this update brings a total of 7 new features. 1 2 3 4 5 The update brings seven new features. ➜ bin . /java -version openjdk version "19" 2022-09-20 OpenJDK Runtime Environment (build 19+36-2238) OpenJDK 64-Bit Server VM (build 19+36-2238, mixed mode, sharing) OpenJDK Java 19 download: https://jdk.

Jakarta EE 10 Released, Opening the Era of Cloud-Native Java

The Eclipse Foundation has released the Jakarta EE 10 platform, Web Profile and the new Core Profile specification. Jakarta EE 10 introduces features for building modern, simplified and lightweight cloud-native Java applications. According to Mike Milinkovich, Executive Director of the Eclipse Foundation This release is a “big release” that is firmly embedded in Jakarta EE in the modern era of microservices and containers. The release of Jakarta EE 10 reflects the work of the global community of contributors, and with this release it now brings key innovations to the cloud-native era that are It is critical to the future of our industry.

Java19 Official GA! See how virtual threads can dramatically increase system throughput

Java19 was released yesterday, bringing a new feature that Java developers have been waiting for - virtual threads. Before Java had this new feature, Golang’s Goroutine had been popular for a long time, and it was a big hit in the field of concurrent programming. With the rapid development and promotion of Golang, it seems that coroutine has become one of the necessary features of the best languages in the world.

JDK 19 / Java 19 Official GA

JDK 19 / Java 19 Official GA JDK 19 / Java 19 has been officially released. The new release contains a total of 7 new JEPs. 405: Record Patterns (Preview) 422: Linux/RISC-V Port 424: Foreign Function & Memory API (Preview) 425: Virtual Threads (Preview) 426: Vector API (Fourth Incubator) 427: Pattern Matching for switch (Third Preview) 428: Structured Concurrency (Incubator) 405: Record Patterns goes to preview stage Record Patterns deconstructs the values of record, and Record patterns and Type patterns enable powerful, declarative, composable forms of data navigation and processing through nesting.

Java 19 officially released, improve multi-threaded, concurrent programming difficulties

Java 19 was officially released a few minutes ago, a non-LTS (long term support) release with seven features including structured concurrency, record mode, a preview of external functions and memory APIs, and support for the open source Linux/RISC-V instruction set architecture (ISA). New Features JEP 405 Record Patterns (preview) JEP 422 Linux/RISC-V Port JEP 424 Foreign Function & Memory API (preview) JEP 425 Virtual Threads (Preview) JEP 426 Vector API (4th incubation)

Microsoft is fully embracing Java!

Although Microsoft has been using the Java language in many of its products, a recent announcement on its website, “Microsoft is committed to the success of Java developers”, has officially sounded the call for Microsoft to fully embrace Java. NET, TypeScript, Visual BASIC, JScript and so on, why did Microsoft go to the trouble of going deeper into Java? Microsoft’s Latest Moves for Java In this announcement, Julia Liuson, President of Microsoft Developer Division, said, “As a company, we are committed to making Java developers as efficient and productive as possible.

Solution for JWT Token auto-renewal

Preface In a front-end/back-end development model, the back-end service issues a jwt token to the user after the front-end user logs in successfully. Each subsequent request will put this token in the request header and pass it to the backend service, which will have a filter to intercept the token and check whether the token is expired, and if the token is expired, the frontend will jump to the login page to log in again.

JavaFX 19 Released

JavaFX 19 is now released, JavaFX 19 requires JDK 11 or higher. This release has enhanced video and CSS features and fixed some touch screen bugs. Additional JavaFX 19 features: Faster creation of observable ArrayList in FXCollections, allowing users to update the list of available printers without restarting the application. Other updates. Added CSS pseudo-classes :focus-visible and :focus-within to support visual focus indication and nested focus visual effects, respectively. A modal behavior fix has been implemented for Stage on Linux platforms.

Best Practices for Java8 Optional

As we all know, Java 8 has a new class - Optional, which is mainly used to solve the common NullPointerException problem in the program. But in the actual development process many people are using Optional in a half-assed way, something like if (userOpt.isPresent()){...} Such code is everywhere. I would prefer to see an honest null judgment, but forcing Optional adds complexity to the code. The article I’m sharing with you today is some of the Best Practise and some of the Bad Practice of Java Optional, for your reference.