You are on page 1of 2

Java Programming

9-1: Java Bytecode


Practice Activities

Lesson Objectives:
• Why understand bytecode?
• How to obtain the bytecode listings
• How to read the bytecode
• How the language constructs are mirrored by the compiler: calculation, method calls

Vocabulary:

Identify the vocabulary word for each definition below.

The opcode that will duplicate the top operand stack value

The opcode that gets the static field from class

The opcode that adds two integer values

Try It/Solve It:


1. Based on the following bytecode, try to convert back to the Java source code

Code:

0: iconst_1
1: istore_0
2: iload_0
3: iconst_1
4: iadd
5: istore_0
6: return

Copyright © 2020, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
2. Based on the following bytecode, try to convert back to the Java source code
Code:
0: iconst_1
1: istore_0
2: iinc 0, 1
5: return

Copyright © 2020, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

You might also like