diff --git a/src/main/java/org/javademos/init/Java16.java b/src/main/java/org/javademos/init/Java16.java index 839f7f94..df08e22a 100644 --- a/src/main/java/org/javademos/init/Java16.java +++ b/src/main/java/org/javademos/init/Java16.java @@ -5,6 +5,7 @@ import org.javademos.commons.IDemo; import org.javademos.java16.extras.J16Demo; import org.javademos.java16.jep338.VectorAPIDemo; +import org.javademos.java16.jep347.Cpp14FeaturesDemo; import org.javademos.java16.jep380.UnixDomainSocketsDemo; import org.javademos.java16.jep386.AlpineLinuxPortDemo; import org.javademos.java16.jep388.WindowsPortDemo; @@ -31,6 +32,8 @@ public static ArrayList getDemos() { java16DemoPool.add(new J16Demo()); // JEP 338 java16DemoPool.add(new VectorAPIDemo()); + // JEP 347 + java16DemoPool.add(new Cpp14FeaturesDemo()); // JEP 380 java16DemoPool.add(new UnixDomainSocketsDemo()); // JEP 386 diff --git a/src/main/java/org/javademos/java16/jep347/Cpp14FeaturesDemo.java b/src/main/java/org/javademos/java16/jep347/Cpp14FeaturesDemo.java new file mode 100644 index 00000000..cd53f567 --- /dev/null +++ b/src/main/java/org/javademos/java16/jep347/Cpp14FeaturesDemo.java @@ -0,0 +1,105 @@ +package org.javademos.java16.jep347; + +import org.javademos.commons.IDemo; + +/// Demo for JDK 16 feature JEP 347 - Enable C++14 Language Features. +/// +/// JEP history: +/// - JDK 16: [JEP 347 - Enable C++14 Language Features](https://openjdk.org/jeps/347) +/// +/// Further reading: +/// - [JEP 347 Specification](https://openjdk.org/jeps/347) +/// - [C++14 Standard](https://en.cppreference.com/w/cpp/14) +/// - [HotSpot JVM Source Code](https://github.com/openjdk/jdk) +/// +/// @author Abhineshhh +public class Cpp14FeaturesDemo implements IDemo { + + @Override + public void demo() { + info(347); + + // JEP 347 is an internal JVM/JDK development change that allowed the HotSpot JVM and JDK libraries + // to be built using C++14 language features instead of being limited to C++98/03. + // + // --- What is this JEP about? --- + // - The JDK is implemented partly in Java and partly in C++ (especially the HotSpot JVM). + // - Before JEP 347, the C++ code in the JDK was written using C++98/03 standards. + // - This JEP updated the minimum C++ language standard to C++14, allowing developers + // to use modern C++ features when writing and maintaining the JVM implementation. + // + // --- Why does this matter? --- + // - Modern C++ features (C++14) provide: + // * Better type safety + // * More expressive syntax (lambda functions, auto type deduction, constexpr, etc.) + // * Improved performance optimizations + // * Easier maintenance and cleaner code + // - This makes the JDK/JVM codebase easier to develop, understand, and optimize. + // + // --- Key C++14 Features Now Available to JDK Developers --- + // 1. **Generic lambdas** - Lambda functions with `auto` parameters + // 2. **Binary literals** - Literals like `0b1010` for binary values + // 3. **Digit separators** - Use `'` in numbers like `1'000'000` + // 4. **Variable templates** - Templates for variables, not just functions/classes + // 5. **Return type deduction** - Functions can use `auto` return type + // 6. **Relaxed constexpr** - More flexibility in compile-time constant expressions + // 7. **[[deprecated]]** attribute - Mark deprecated functions + // 8. **std::make_unique** - Smart pointer creation utility + // + // --- Example of C++14 Benefits (Conceptual C++ Code) --- + // Before (C++98/03): + // template + // T add(T a, T b) { return a + b; } + // + // After (C++14): + // auto add(auto a, auto b) { return a + b; } // Generic lambda! + // + // --- Impact on Java Developers --- + // - **No direct impact on Java code** - This JEP does not introduce new Java language features. + // - Java developers won't write C++ code or use C++14 features in their applications. + // - The benefits are indirect: + // * Better JVM performance and stability + // * Faster development of new JVM features + // * Improved code quality in the JVM implementation + // + // --- How to Verify This Change --- + // Since this is a build-time change affecting JDK developers (not Java users), + // there's no Java API or runtime behavior to demonstrate. + // + // The change can only be observed by: + // 1. Examining the JDK source code repository (https://github.com/openjdk/jdk) + // 2. Checking the build requirements which now specify C++14-compatible compilers + // 3. Looking at HotSpot/JDK C++ source files that use C++14 features + // + // --- Summary --- + // JEP 347 modernized the internal development of the JDK by allowing C++14 language features + // in the JVM and JDK C++ codebase. This improves code maintainability, safety, and performance, + // but is transparent to Java application developers. + // + // --- JEP 347 Overview --- + // - Scope: Internal JDK/JVM development (C++ codebase) + // - Change: Minimum C++ standard updated from C++98/03 to C++14 + // - Target: HotSpot JVM and JDK library developers + // - Impact on Java developers: Indirect (better JVM quality) + // + // --- Key C++14 Features Now Available --- + // 1. Generic lambdas with auto parameters + // 2. Binary literals and digit separators + // 3. Variable templates + // 4. Return type deduction with auto + // 5. Relaxed constexpr restrictions + // 6. [[deprecated]] attribute + // 7. std::make_unique smart pointer utility + // + // --- Benefits --- + // - More maintainable JVM source code + // - Better type safety and performance + // - Easier implementation of new JVM features + // - Modernized development workflow for JDK contributors + // + // --- For Java Developers --- + // - No new Java APIs or language features + // - Transparent change (no code changes needed) + // - Benefit from improved JVM quality and performance + } +} diff --git a/src/main/resources/JDK16Info.json b/src/main/resources/JDK16Info.json index a8bdcdc4..fd4c1b38 100644 --- a/src/main/resources/JDK16Info.json +++ b/src/main/resources/JDK16Info.json @@ -7,6 +7,14 @@ "link": true, "code": false }, + { + "jep": 347, + "jdk": 16, + "name": "JEP 347 - Enable C++14 Language Features", + "dscr": "Allows the JDK C++ source code to be compiled using C++14 language features, improving code quality and maintainability.", + "link": false, + "code": false + }, { "jep": 380, "jdk": 16,