1 2 /* 3 4 The author of this software is Ian Kaplan 5 Bear Products International 6 www.bearcave.com 7 iank@bearcave.com 8 9 Copyright (c) Ian Kaplan, 1999, 2000 10 11 See copyright file for usage and licensing 12 13 */ 14 15 package attr; 16 17 import java.io.*; 18 import util.*; 19 import jconst.*; 20 21 22 /** 23 24 This class represents the line number table attribute. 25 26 <p> 27 The line number table attribute may be assocated with a code 28 attribute (see codeAttr object). 29 30 <p> 31 The JVM Spec (4.7.6) states: 32 33 <blockquote> 34 It [the line number table attribute] may be used by debuggers to 35 determine which part of the Java Virtual Machine code array 36 corresponds to a given line number in the original Java source 37 file. If LineNumberTable attributes are present in the attributes 38 table of a given Code attribute, then they may appear in any 39 order. Furthermore, multiple LineNumberTable attributes may 40 together represent a given line of a Java source file; that is, 41 LineNumberTable attributes need not be one-to-one with source 42 line 43 </blockquote> 44 45 <p> 46 The LineNumberTable attribute has the format 47 48 <pre> 49 LineNumberTable_attribute { 50 u2 attribute_name_index; 51 u4 attribute_length; 52 u2 line_number_table_length; 53 lineEntry line_number_table[line_number_table_length]; 54 } 55 </pre> 56 57 <p> 58 The attribute_name_index and attribute length are read by the 59 attrFactory.allocAttr method. These values are passed into the class 60 constructor. 61 62 <p> 63 The line number entries have the format: 64 65 <pre> 66 lineEntry { 67 u2 start_pc; 68 u2 line_number; 69 } 70 </pre> 71 72 @author Ian Kaplan 73 */ 74 public class lineNumTabAttr extends attrInfo { 75 76 // 77 // lineEntry 78 // 79 // This object represents a line table entry. 80 // 81 class lineEntry { 82 private int start_pc; 83 private int line_number; 84 85 lineEntry( DataInputStream dStream ) { 86 start_pc = readU2( dStream ); 87 line_number = readU2( dStream ); 88 } 89 90 int getStartPC() { return start_pc; }; 91 int getLineNum() { return line_number; } 92 } // lineEntry 93 94 lineEntry lineNumTab[] = null; 95 96 public lineNumTabAttr( String name, int length, 97 DataInputStream dStream ) { 98 super( name, length ); 99 100 int numEntries = readU2( dStream ); 101 if (numEntries > 0) { 102 lineNumTab = new lineEntry[ numEntries ]; 103 for (int i = 0; i < numEntries; i++) { 104 lineNumTab[i] = new lineEntry( dStream ); 105 } 106 } 107 } // lineNumTabAttr 108 109 } // lineNumTabAttr 110