Skip to content
Ameen Abozaid
Planned lessonMID-001-L03

Reading bytecode with javap

  • Lesson 3 of 6
  • Mid-level
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

read the bytecode of a small method and map it to source.

Planned topics

  • javap -c -p Shop disassembles a class, including private members.
  • The JVM is a stack machine: instructions push and pop an operand stack.
  • Common instructions: iload, imul, invokevirtual, invokestatic, ireturn.
  • Local variables sit in numbered slots; slot 0 is this in instance methods.
  • Lambdas appear as invokedynamic; modern JDKs also use it for string concatenation (verify version before recording).
Draft outline details

Demonstration

java
static int total(int price, int qty) { return price * qty; }
text
iload_0
iload_1
imul
ireturn

Check your understanding

In total, what does imul consume?

Show answer

The two top operand-stack values.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.