Professional Documents
Culture Documents
JP 8 2 Practice Solution
JP 8 2 Practice Solution
Lesson Objectives:
• Understand the class file structure
• Identify the Access field
• Identify the Method structure and bytecode
• Method Info: Code_attribute
• Code Attribute: LineNumberTable_attribute
• Class Attribute: SourceFile_attribute
Vocabulary:
Method info A table in a Class file that describes the method in the class or inter-face
JDB
int test=100;
javac EmptyCode
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.
3. Specify the number of constant pool entries in the EmptyCode class file.
Solution 1: There are 16 entries in the constant pool of the EmptyCode class file.
#5 = Utf8 test
#6 = Utf8 I
#7 = Utf8 <init>
#8 = Utf8 ()V
#9 = Utf8 Code
Solution 2:
4. Determine how many field definitions are in the EmptyCode class file.
<init>
7. What is the bytecode for the super() statement in the EmptyCode class?
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
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
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.