انتقل إلى المحتوى
أمين أبوزيد
MID-001

معمارية JVM

  • 6 درس
  • 3 ساعة تدريب (تقدير)
في هذه الصفحة 8 موضوعات

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

نظرة عامة

الموضوعات

  • تحميل الأصناف (Class loading)
  • الشيفرة الثنائية (Bytecode)
  • مناطق بيانات وقت التشغيل
  • الترجمة الفورية (JIT compilation)

تعلّم أولًا

3 ساعة تدريب (تقدير)

مخرجات التعلم

  1. Describe class loading (loading, linking, initialization) and the class-loader hierarchy.
  2. Read bytecode for a small method with javap -c and relate it to the source.
  3. Name the runtime data areas (heap, stacks, metaspace, code cache) and what lives in each.
  4. Explain interpretation, JIT compilation (C1/C2, tiered), and why performance changes during warm-up.

الدروس

  1. 01من ملف .class إلى كود يعمل
  2. 02تحميل الأصناف ومحمّلاتها (Class loaders)
  3. 03قراءة الـ Bytecode باستخدام javap
  4. 04مناطق بيانات وقت التشغيل
  5. 05مُترجم JIT والإحماء (Warm-up)
  6. 06عرض عملي: مراقبة JIT باستخدام -XX:+PrintCompilation

المختبر والتمارين

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)

IDOutcomeTask
MID-001-EX011Print the class loader of String, a Shop class, and java.sql.Connection; explain each result.
MID-001-EX022Run javap -c -p on a class with total(int,int) and annotate each instruction.
MID-001-EX032Compile if (qty > 0) return price * qty; else return 0; and identify the branch instruction.
MID-001-EX043Draw the runtime data areas and place: an Order object, a local int, a class's method table, JIT output.
MID-001-EX054Run a timing loop with and without warm-up; explain the difference.
MID-001-EX061Scenario: NoClassDefFoundError after deploy though the build passed. Give two likely causes.
أظهر الحلول
  • EX01 String gives null (bootstrap); the Shop class gives the application loader; java.sql.Connection gives the platform loader.
  • EX02 iload_0/iload_1 push arguments, imul multiplies, ireturn returns the top value.
  • EX03 A conditional jump such as ifle skips to the return 0 path.
  • EX04 Object on heap; local int in 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. ClassNotFoundException would 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.

اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.

  1. 1The three class-loading phases are:O1
  2. 2Which loader loads java.lang.String?O1
  3. 3A class compiled fine but is absent at runtime. You typically get:O1
  4. 4Class.forName("x.Missing") with no such class throws:O1
  5. 5The JVM executes bytecode using an:O2
  6. 6iload_0; iload_1; iadd; ireturn returns:O2
  7. 7Class metadata lives in:O3
  8. 8JIT-compiled machine code lives in:O3
  9. 9In tiered compilation, which compiler applies the heaviest optimization?O4
  10. 10First requests after startup are slow mainly because:O4

الجزء العملي

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).

اكتب للبحث في المستويات والمراحل والوحدات والدروس.