معمارية JVM
في هذه الصفحة 8 موضوعات
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
نظرة عامة
الموضوعات
- تحميل الأصناف (Class loading)
- الشيفرة الثنائية (Bytecode)
- مناطق بيانات وقت التشغيل
- الترجمة الفورية (JIT compilation)
تعلّم أولًا
3 ساعة تدريب (تقدير)
مخرجات التعلم
- Describe class loading (loading, linking, initialization) and the class-loader hierarchy.
- Read bytecode for a small method with
javap -cand relate it to the source. - Name the runtime data areas (heap, stacks, metaspace, code cache) and what lives in each.
- Explain interpretation, JIT compilation (C1/C2, tiered), and why performance changes during warm-up.
الدروس
المختبر والتمارين
Lab
MID-001-LAB1 · Warm-up effect
Outcomes: 1–4 · Time: ~3 h Start Shop and send 5,000 checkout requests with a simple load tool, recording each latency. Plot the first 1,000 requests against steady state. Repeat with -XX:+PrintCompilation and mark compilation events on the timeline. Explain the curve. Acceptance: chart plus explanation referencing JIT tiers.
Exercises (assessment: bytecode-reading quiz, a class-loading scenario, and the lab)
| ID | Outcome | Task |
|---|---|---|
| MID-001-EX01 | 1 | Print the class loader of String, a Shop class, and java.sql.Connection; explain each result. |
| MID-001-EX02 | 2 | Run javap -c -p on a class with total(int,int) and annotate each instruction. |
| MID-001-EX03 | 2 | Compile if (qty > 0) return price * qty; else return 0; and identify the branch instruction. |
| MID-001-EX04 | 3 | Draw the runtime data areas and place: an Order object, a local int, a class's method table, JIT output. |
| MID-001-EX05 | 4 | Run a timing loop with and without warm-up; explain the difference. |
| MID-001-EX06 | 1 | Scenario: NoClassDefFoundError after deploy though the build passed. Give two likely causes. |
أظهر الحلول
- EX01
Stringgivesnull(bootstrap); the Shop class gives the application loader;java.sql.Connectiongives the platform loader. - EX02
iload_0/iload_1push arguments,imulmultiplies,ireturnreturns the top value. - EX03 A conditional jump such as
ifleskips to thereturn 0path. - EX04 Object on heap; local
intin the thread's stack frame; method table in metaspace; JIT output in the code cache. - EX05 The cold loop includes interpretation and compilation; after warm-up the same code is much faster.
- EX06 A dependency JAR missing from the runtime classpath (compile vs runtime scope mismatch), or a static initializer that threw earlier.
ClassNotFoundExceptionwould instead be a failed by-name lookup. - Outcome 4 is also covered by the lab and Q09-Q10.
الاختبار
Outcomes: O1 class loading · O2 bytecode · O3 data areas · O4 JIT and warm-up.
اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.
الجزء العملي
Six exercises MID-001-EX01 to EX06 plus the lab with its chart. Pass: at least five exercises correct and a lab explanation that names the JIT tiers.
أخطاء شائعة
Benchmarking cold code; assuming the JVM runs bytecode as written.
التقييم
Bytecode-reading quiz and a class-loading scenario (NoClassDefFoundError vs ClassNotFoundException).
الصلة بالمسار الوظيفي
Basis for memory tuning (MID-002) and profiling (MID-008).