1   package jrre.classloader.classfile.attributes;
2   
3   import jrre.classloader.classfile.InstructionDecoder;
4   
5   public class CodeAttribute extends Attribute{
6   
7       private int nameIndex,length,maxStack,maxLocals,codeLength,exceptionTableLength,attributesCount;
8       private ExceptionTable exceptionTable;
9       private LocalVariableAttributeTable localVariableAttributeTable;
10      private Code code;
11  
12      public CodeAttribute(){}
13  
14      public CodeAttribute(int nameIndex, int length, int maxStack, int maxLocals, int codeLength, Code code,
15  			 int exceptionTableLength){
16  
17  	this.nameIndex = nameIndex;
18  	this.length = length;
19  	this.maxStack = maxStack;
20  	this.maxLocals = maxLocals;
21  	this.codeLength = codeLength;
22  	this.code = code;
23  	this.exceptionTableLength = exceptionTableLength;
24      }
25  
26      public void setExceptionTable(ExceptionTable exceptionTable){ this.exceptionTable = exceptionTable; }
27  
28      public void setLocalVariableAttributeTable(LocalVariableAttributeTable localVariableAttributeTable){
29          this.localVariableAttributeTable = localVariableAttributeTable;
30      }
31  
32      public int getExceptionTableLength(){ return exceptionTableLength; }
33  
34      public jrre.StackFrame getStackFrame(){
35  
36          jrre.StackFrame stackFrame = new jrre.StackFrame();
37  
38          //stackFrame.setByteCode(code.getByteCode());
39          stackFrame.setInstructions(InstructionDecoder.decode(code.getByteCode()));
40          //?
41          if(localVariableAttributeTable != null) {
42              //stackFrame.setLocalVariableTable(localVariableAttributeTable);
43              stackFrame.setLocalVariableSize(localVariableAttributeTable.getLocalVariableEntryCount());
44          }
45          return stackFrame;
46      }
47  
48      public String toString(){
49          StringBuffer toReturn = new StringBuffer();
50  
51  	toReturn.append("Code Attribute:");
52  	toReturn.append("\n\t\tName Index: "+nameIndex);
53  	toReturn.append("\n\t\tLength: "+length);
54  	toReturn.append("\n\t\tMax Stack: "+maxStack);
55  	toReturn.append("\n\t\tMax Locals: "+maxLocals);
56  	toReturn.append("\n\t\tByte Code Length: "+codeLength);
57  	toReturn.append("\n\t\t"+code+"\n");
58  	toReturn.append("\n\t\tException Table Length: "+exceptionTableLength);
59  	if(exceptionTableLength > 0) toReturn.append(exceptionTable);
60  
61  	return toReturn.toString();
62      }
63  
64  }
This page was automatically generated by Maven