Skip to content

tamkhaivo/java_mastery

Repository files navigation

java_mastery

Java 25 - Learning Methods

Modules

Java 25 Mastery Curriculum

Module 1: Under the Hood (The JVM)

  • The Lifecycle of a Java Class: Compilation (javac), Bytecode, Classloading.
  • Deep Dive: Bytecode: Reading .class files with javap -c -v -p module1.SimpleLifecycle.
  • Memory Management: Stack vs. Heap, Object Layout, Garbage Collection basics.
    • Heap dump: jmap -histo:live <PID> | head -n 10
    • Stack Frame dump: jstat -gcutil <PID> 500
    • Live Memory dump: jstat -gc <PID> 500
  • Garbage Collection: Types of GC (Serial, Parallel, CMS, G1), Tuning.
    • Serial GC: java -XX:+UseSerialGC - Low Overhead - Best Use Case:Tiny scripts, Lambda functions
    • Parallel GC: java -Xmx200m -XX:+UseParallelGC -Xlog:gc:stdout module1.MemoryDemo - Max Throughput │ Number crunching, ETL jobs.
    • CMS GC: java -XX:+UseConcMarkSweepGC -Xmx200m -Xlog:gc:stdout module1.MemoryDemo - Balanced │ Web servers, standard apps (Default).
    • G1 GC: java -XX:+UseG1GC -Xmx200m -Xlog:gc:stdout module1.MemoryDemo - Min Latency │ Real-time apps, massive datasets.
  • Execution Engine: Interpreter vs. JIT Compiler (C1/C2), Native Code.
    • JIT Compilation: java -XX:+PrintCompilation module1.JITDemo | grep "performCalculation"
      • Compare Tiers: java -XX:TieredStopAtLevel=1 module1.JITDemo vs java -XX:TieredStopAtLevel=4 module1.JITDemo
    • Native Code: javac -h module1.JITDemo

Module 2: Modern Java Syntax & Safety (Project Amber)

  • Data Modeling: Records, Sealed Classes/Interfaces.
    • javap -p module2.User
    • javap -v module2.TransactionStatus
    • javap -v module2.TransactionStatus | grep "Permitted" -A 3
  • Control Flow: Pattern Matching for switch, Record Patterns.
  • Text & Formatting: String Templates (if available/preview), Text Blocks.

Module 3: Next-Gen Concurrency (Project Loom)

  • Virtual Threads: The M:N threading model, lightweight threads.
  • Structured Concurrency: Managing thread lifecycles safely.
    • javac module3.StandardConcurrency.java
    • java module3.StandardConcurrency
    • StructuredTaskScope is in preview, so we need to use --enable-preview flag.
  • Scoped Values: Efficient alternatives to ThreadLocal.
    • javac --release 25 --enable-preview module3/ScopedValuesDemo.java
    • java --enable-preview module3.ScopedValuesDemo

Module 4: High Performance & Native Interop (Project Panama & Vector)

  • Foreign Function & Memory API: Calling C code without JNI.
    • javac --release 25 --enable-preview module4/PanamaHello.java
    • java --enable-native-access=ALL-UNNAMED module4.PanamaHello
  • Vector API: SIMD (Single Instruction, Multiple Data) programming in Java.
    • javac --add-modules jdk.incubator.vector module4/VectorDemo.java
    • java --add-modules jdk.incubator.vector module4.VectorDemo

Module 5: Advanced Runtime Tuning

  • JVM Flags: Tuning heap, GC algorithms (ZGC, G1).
  • CDS (Class Data Sharing): Fast startup.
    • javac module5/HelloWorld.java
    • time java module5.HelloWorld
    • java -Xshare:dump -XX:SharedArchiveFile=app.jsa -cp . module5.HelloWorld
    • time java -Xshare:on -XX:SharedArchiveFile=app.jsa -cp . module5.HelloWorld

Module 6: Capstone (The Ultimate Combination)

  • Risk Analysis Server: Virtual Threads (Concurrency) + Vector API (Throughput).
    • javac --add-modules jdk.incubator.vector module6/RiskAnalysisServer.java
    • java --add-modules jdk.incubator.vector module6.RiskAnalysisServer

Module 7: Advanced GC Optimizations

Focuses on Stability in long-running systems.

  • Key Metrics: Latency, Throughput, Memory Footprint.
  • Demo: LongRunningGCStability.java simulates a server under load to visualize GC impact.

About

Java 25 - Learning Methods

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors