1. Loading and Verifying Bytecode✅ Class LoaderThe JVM loads .class files into memory when a Java program starts.Uses lazy loading (loads classes only when needed).✅ Bytecode VerificationChecks if the bytecode follows Java security rules (prevents unsafe operations).Ensures memory safety (e.g., no illegal memory access). | 2. Memory Management✅ Heap and Stack ManagementJVM divides memory into different areas:Heap – Stores objects and class metadata.Stack – Stores method calls and local variables.✅ Garbage Collection (GC)Automatically removes unused objects to free up memory.Uses algorithms like Mark and Sweep, G1 (Garbage First).
|
3. Bytecode Execution✅ Interpretation & Just-In-Time (JIT) CompilationConverts bytecode (.class files) into machine code.Uses two execution modes:Interpreter – Translates bytecode line-by-line (slower).JIT Compiler – Compiles frequently used bytecode into native code for faster execution.✅ Execution EngineRuns the compiled machine code.Optimizes performance using methods like caching, inlining, and loop unrolling. | 4. Exception Handling✅ Manages Exceptions at RuntimeCatches and handles runtime errors like NullPointerException, ArrayIndexOutOfBoundsException.Uses try-catch-finally blocks for structured error handling. |
5. Security Enforcement✅ Sandboxing & Security ManagerJVM restricts code execution to prevent unauthorized access to system resources.Uses bytecode verification and security policies to block malicious code. | 6. Multithreading Support✅ Thread ManagementAllows programs to run multiple tasks concurrently.Uses Java Threads and manages thread synchronization (e.g., synchronized keyword).Optimizes CPU usage by scheduling threads efficiently. |
7. Native Interface (JNI – Java Native Interface)✅ Interaction with Native Code (C/C++)Allows Java programs to call native methods written in C or C++.Used in performance-critical applications (e.g., databases, system utilities). | |