1 23 24 25 package com.sun.jdo.api.persistence.enhancer.classfile; 26 27 import java.io.*; 28 29 33 34 public class LineNumberTableAttribute extends ClassAttribute { 35 36 public final static String expectedAttrName = "LineNumberTable"; 38 39 private short lineNumbers[]; 40 41 42 private InsnTarget targets[]; 43 44 45 46 49 public LineNumberTableAttribute( 50 ConstUtf8 nameAttr, short lineNums[], InsnTarget targets[]) { 51 super(nameAttr); 52 lineNumbers = lineNums; 53 this.targets = targets; 54 } 55 56 57 58 static LineNumberTableAttribute read( 59 ConstUtf8 attrName, DataInputStream data, CodeEnv env) 60 throws IOException { 61 int nLnums = data.readUnsignedShort(); 62 short lineNums[] = new short[nLnums]; 63 InsnTarget targs[] = new InsnTarget[nLnums]; 64 for (int i=0; i<nLnums; i++) { 65 targs[i] = env.getTarget(data.readShort()); 66 lineNums[i] = data.readShort(); 67 } 68 return new LineNumberTableAttribute(attrName, lineNums, targs); 69 } 70 71 void write(DataOutputStream out) throws IOException { 72 out.writeShort(attrName().getIndex()); 73 int nlines = lineNumbers.length; 74 out.writeInt(2+4*nlines); 75 out.writeShort(nlines); 76 for (int i=0; i<nlines; i++) { 77 out.writeShort(targets[i].offset()); 78 out.writeShort(lineNumbers[i]); 79 } 80 } 81 82 void print(PrintStream out, int indent) { 83 ClassPrint.spaces(out, indent); 84 out.println("Line Numbers: "); for (int i=0; i<lineNumbers.length; i++) { 86 ClassPrint.spaces(out, indent+2); 87 out.println(Integer.toString(lineNumbers[i]) + " @ " + Integer.toString(targets[i].offset())); 89 } 90 } 91 } 92 93 | Popular Tags |