- Java 10 - Discussion
- Java 10 - Useful Resources
- Java 10 - Quick Guide
- Java 9 Tutorial
- Java 8 Tutorial
- Java Tutorial
- Java 10 - Thread-local Handshake
- Java 10 - Root Certificate
- Java 10 - Consolidated JDK Forest
- Java 10 - Heap Allocation
- Java 10 - Locale Enhancement
- Java 10 - Enhanced Garbage Collection
- Java 10 - Class-Data Sharing
- Java 10 - JIT Compiler
- Java 10 - Deprecated Features & Options
- Java 10 - Removed Features & Options
- Java 10 - New APIs & Options
- Java 10 - Local Variable Type Inference
- Java 10 - Time Based Release Versioning
- Java 10 - Environment Setup
- Java 10 - Overview
- Java 10 - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java 10 - Class-Data sharing
JEP 310 − Apppcation Class-Data Sharing
When JVM starts it loads the classes in memory as a prepminary step. In case there are multiple jars having multiple classes, an evident lags appears for the first request. In serverless architecture, such a lag can delay the boot time which is a critical operation in such an architecture. Apppcation class-data sharing concept helps in reducing the start up time of an apppcation. Java has an existing CDS (Class-Data Sharing) feature. With Apppcation class-data sharing, Java 10 allows to put apppcation classes in a shared archive. This reduces the apppcation startup and footprint by sharing a common class meta data across multiple java processes.
Process
Apppcation Class data sharing is a 3 step process.
Create a pst of Classes to archive − Create a pst welcome.lst of a class Greeting.java lying in welcome.jar using Java Launcher.
$java -Xshare:off -XX:+UseAppCDS -XX:DumpLoadedClassList=welcome.lst -cp welcome.jar Greeting
Create AppCDS archive − Archive a pst of classes to be used for Apppcation class data sharing.
$java -Xshare:dump -XX:+UseAppCDS -XX:SharedClassListFile=welcome.lst -XX:SharedArchiveFile=welcome.jsa -cp welcome.jar
Use AppCDS archive − Use AppCDS archive while using java launcher.
$java -Xshare:on -XX:+UseAppCDS -XX:SharedArchiveFile=welcome.jsa -cp welcome.jar GreetingAdvertisements