I. Introduction
Java 19 is here, and it brings a host of new features and improvements to the
world’s most popular programming language. Whether you are a seasoned Java
developer or a beginner looking to learn more, you will find something exciting
and useful in this latest release.
Java 19 introduces several new features and improvements that enhance the Java
language and platform. Some of the most notable features are:
-
Structured concurrency: This feature simplifies multithreaded
programming by treating multiple tasks running in different threads as a
single unit of work. This improves error handling, cancellation,
reliability, and observability of concurrent code.
Structured concurrency is implemented by a new API called StructuredTaskScope that allows creating and managing concurrent tasks in a structured way.
-
Record patterns: This feature extends pattern matching to
deconstruct record values. Record patterns allow expressing more
sophisticated and composable data queries without changing the syntax or
semantics of type patterns.
Record patterns are part of Project Amber, which explores and incubates smaller, productivity-oriented Java features.
-
Foreign function and memory API: This feature introduces an API
that enables Java programs to interoperate with code and data outside
the Java runtime. The API allows efficiently invoking foreign functions
(code outside the JVM) and safely accessing foreign memory (memory not
managed by the JVM) without using the Java Native Interface (JNI).
The foreign function and memory API combines two earlier incubating APIs: the foreign memory access API and the foreign linker API.
-
Virtual threads: This feature introduces lightweight threads that
reduce the effort of writing, maintaining, and observing
high-throughput, concurrent applications. Virtual threads are managed by
the JVM rather than by the operating system, which allows creating
millions of them without consuming much memory or resources.
Virtual threads are also part of Project Loom, which introduces a new lightweight concurrency model for Java.
-
Vector API: This feature introduces an API that allows expressing
computations that operate on multiple values at once (vector
computations). The API leverages vector instructions available on modern
CPUs to achieve higher performance for data-intensive operations.
The vector API is part of Project Panama, which aims to improve native interoperation with non-Java code.
-
Linux/RISC-V port: This feature ports the JDK to the open-source
Linux/RISC-V architecture. RISC-V is a free and open-source instruction
set architecture that offers many benefits for performance, security,
modularity, extensibility, and innovation.
The Linux/RISC-V port sets the stage for easier Linux/RISC-V implementations by integrating this port into the JDK.
In this blog post, we will focus on one of the most intriguing features of
Java 19: the Linux/RISC-V port. This feature enables Java developers to run
their applications on the open-source RISC-V architecture, which offers many
benefits for performance, security, and innovation.
Read on to find out what RISC-V is, why it matters for open-source
development, and how you can get started with Java 19 on RISC-V
today.
II. Body
1. Linux/RISC-V port:
What RISC-V is and how it differs from other architectures
RISC-V is a free and open instruction set architecture (ISA) based on reduced instruction set computer (RISC) principles. RISC-V uses a smaller and simpler instruction set compared to complex instruction set computer (CISC) architectures, such as x86 and ARM. RISC-V also supports various extensions for different domains and applications, such as floating point, vector, cryptography, and Linux support. RISC-V was developed at UC Berkeley as a research project in 2010 and later became an open standard maintained by RISC-V International, a non-profit organization with over 300 members.
RISC-V differs from other architectures in several ways. First, RISC-V is open source and royalty-free, meaning anyone can use it without paying fees or licenses to anyone. This allows more innovation and customization for different needs and markets. Second, RISC-V is modular and extensible, meaning it has a minimal base ISA that can be extended with optional standard or custom extensions.
This allows creating processors that are tailored for specific applications without compromising compatibility or portability. Third, RISC-V is stable and future-proof, meaning it has a fixed base ISA that will not change over time. This ensures backward compatibility and avoids fragmentation or obsolescence of existing code or hardware.
Using RISC-V for open-source development has several benefits, such as:
- Low cost: RISC-V is free and open source, meaning developers do not have to pay any fees or licenses to use it. This can save millions of dollars in development costs and enable more innovation and competition.
- High performance: RISC-V is based on RISC principles, meaning it uses a smaller and simpler instruction set that can execute faster and more efficiently than complex instruction set architectures (CISC) such as x86 and ARM.
RISC-V also supports various extensions that can optimize performance for different applications and domains. - Modularity: RISC-V is modular and extensible, meaning it has a minimal base instruction set that can be extended with optional standard or custom extensions. This allows creating processors that are tailored for specific needs and markets without compromising compatibility or portability.
- Security: RISC-V is open source, meaning anyone can inspect and verify its design and implementation. This reduces the risk of hidden vulnerabilities or backdoors that could compromise security or privacy.
RISC-V also supports extensions that can enhance security features such as encryption, authentication, and isolation. - Innovation: RISC-V is open source, meaning anyone can contribute to its development and improvement. This fosters a collaborative community of developers, researchers, and enthusiasts who can share ideas, feedback, and solutions.
This also enables more experimentation and exploration of new possibilities with RISC-V.
These are some of the benefits of using RISC-V for open-source development that make it an attractive alternative to traditional architectures.
Examples of RISC-V projects and applications in various domains
RISC-V is being used for a wide range of projects and applications across different domains and markets. Some examples are:
- AI: RISC-V enables creating custom processors for artificial intelligence (AI) applications that can optimize performance, power efficiency, and flexibility. For instance, Kendryte K210 is a RISC-V-based system-on-chip (SoC) that integrates neural network processors for machine vision and machine learning.
The example is Esperanto Technologies’ ET-SoC-1, which uses 1,088 RISC-V cores to accelerate AI workloads. - IoT: RISC-V enables creating low-cost and low-power processors for internet of things (IoT) devices that can support various connectivity and security features.
For instance, SiFive’s FE310 is a RISC-V-based microcontroller that powers the HiFive1 development board for IoT applications3.
Another example is GreenWaves Technologies’ GAP8, which uses eight RISC-V cores to enable energy-efficient edge computing for IoT devices. - Embedded: RISC-V enables creating embedded processors that can run various operating systems and software stacks. For instance, Microchip’s PolarFire SoC is a RISC-V-based SoC that integrates FPGA fabric and supports Linux-based embedded applications.
And an example is Andes Technology’s N22 core, which uses a 32-bit RISC-V ISA to enable embedded applications such as smart meters and sensors. - Education: RISC-V enables creating educational platforms that can teach students about computer architecture and design. For instance, PULP Platform’s PULPino is a RISC-V-based microcontroller that can be used for teaching and research purposes.
An example is Sipeed’s MAixduino Kit Dock Suit with M1w Dock & ESP32 Module & OV2640 Camera Module & 2.4-inch LCD Display Development Board Based on Kendryte K210 AI Processor Support Face Recognition Compatible with Arduino IDE, which uses a RISC-V-based AI processor to enable learning about machine vision.
These are some of the examples of RISC-V projects and applications in various domains that demonstrate its versatility and potential.
2. Java on RISC-V
Java on RISC-V is an effort to port the Java virtual machine (JVM) and the Java development kit (JDK) to run on the RISC-V architecture. This would enable Java developers to leverage the benefits of RISC-V for their applications and platforms.
Java on RISC-V is currently under development by several contributors, including Huawei, Alibaba, and Red Hat. The project aims to integrate a Linux/RISC-V port into JDK 19 by September 2022.
Java on RISC-V faces some challenges and opportunities in running Java on a new architecture. Some of the challenges include adapting the JVM and JDK code base to support RISC-V features and extensions, optimizing performance and compatibility, testing and debugging across different hardware platforms, and collaborating with the open-source community.
Some of the opportunities include exploring new possibilities with RISC-V extensions such as vector operations, cryptography, and machine learning, enhancing security and reliability with RISC-V’s open-source nature, and contributing to the innovation and growth of both Java and RISC-V ecosystems.
How JDK 19 integrates the Linux/RISC-V port into the JDK
JDK 19 integrates the Linux/RISC-V port as an incubator feature that allows running Java applications on Linux systems with RISC-V processors. The port provides a new platform-specific implementation of HotSpot VM and JDK libraries that support the RV64G configuration of RISC-V ISA.
The port also supports vector operations using RISC-V’s vector extension. The port is based on a snapshot of OpenJDK mainline from May 2021 and has passed some JTReg tests. The port is expected to be ready for general availability by JDK 20.
The Linux/RISC-V port is a collaborative effort by several contributors, including Huawei, Alibaba, and Red Hat. The port aims to enable Java developers to leverage the benefits of RISC-V for their applications and platforms.
The port also contributes to the innovation and growth of both Java and RISC-V ecosystems.
Some benchmarks and comparisons of Java performance on RISC-V versus other architectures
Java performance on RISC-V depends on several factors, such as the implementation of the JVM and JDK, the hardware platform and configuration, the type and size of the workload, and the optimization level. There are not many publicly available benchmarks and comparisons of Java performance on RISC-V versus other architectures yet, but some preliminary results have been reported by different sources.
One source is a paper by Maas et al. (2020), which presents a high-performance JIT compiler for Java on RISC-V based on JikesRVM. The paper compares Java performance on RISC-V with x86-64 using two FPGA-based platforms: VC707 with 1.5 GHz Rocket core and VCU118 with 3 GHz Ariane core. The paper uses SPECjvm2008 as the benchmark suite and reports that Java performance on RISC-V is within 10% of x86-64 for most workloads.
Another source is a presentation by Yang et al. (2021), which introduces Huawei’s port of OpenJDK to Linux/RISC-V based on JDK 17. The presentation compares Java performance on RISC-V with ARM64 using two platforms: HiFive Unmatched with 1.5 GHz U740 core and Kunpeng920 with 2.6 GHz ARMv8-A core. The presentation uses DaCapo as the benchmark suite and reports that Java performance on RISC-V is within 20% of ARM64 for most workloads.
These results suggest that Java performance on RISC-V is competitive with other architectures, especially considering that RISC-V is still a relatively new ISA that has room for improvement and optimization.
III. Conclusion
In this blog post, we have explored one of the most intriguing features of Java 19: the Linux/RISC-V port. We have learned what RISC-V is and how it differs from other architectures.
We have also seen the benefits of using RISC-V for open-source development and some examples of RISC-V projects and applications in various domains.
Finally, we have discussed how JDK 19 integrates the Linux/RISC-V port into the JDK and how Java performance on RISC-V compares with other architectures.
We hope this blog post has sparked your interest in Java 19 and RISC-V and encouraged you to try out JDK 19 on RISC-V and provide feedback.
Related Articles: