1 11 package org.eclipse.jdt.internal.core.util; 12 13 import org.eclipse.jdt.core.util.ClassFormatException; 14 import org.eclipse.jdt.core.util.IConstantPool; 15 import org.eclipse.jdt.core.util.IStackMapFrame; 16 import org.eclipse.jdt.core.util.IStackMapTableAttribute; 17 21 public class StackMapTableAttribute 22 extends ClassFileAttribute 23 implements IStackMapTableAttribute { 24 25 private static final IStackMapFrame[] NO_FRAMES = new IStackMapFrame[0]; 26 private static final byte[] NO_ENTRIES = new byte[0]; 27 28 private int numberOfEntries; 29 private IStackMapFrame[] frames; 30 31 private byte[] bytes; 32 33 40 public StackMapTableAttribute( 41 byte[] classFileBytes, 42 IConstantPool constantPool, 43 int offset) 44 throws ClassFormatException { 45 super(classFileBytes, constantPool, offset); 46 47 final int length = u2At(classFileBytes, 6, offset); 48 this.numberOfEntries = length; 49 if (length != 0) { 50 int readOffset = 8; 51 this.frames = new IStackMapFrame[length]; 52 for (int i = 0; i < length; i++) { 53 StackMapFrame frame = new StackMapFrame(classFileBytes, constantPool, offset + readOffset); 54 this.frames[i] = frame; 55 readOffset += frame.sizeInBytes(); 56 } 57 } else { 58 this.frames = NO_FRAMES; 59 } 60 final int byteLength = (int) u4At(classFileBytes, 2, offset); 61 62 if (length != 0) { 63 System.arraycopy(classFileBytes, offset + 6, this.bytes = new byte[byteLength], 0, byteLength); 64 } else { 65 this.bytes = NO_ENTRIES; 66 } 67 } 68 69 public int getNumberOfEntries() { 70 return this.numberOfEntries; 71 } 72 73 public IStackMapFrame[] getStackMapFrame() { 74 return this.frames; 75 } 76 77 79 public byte[] getBytes() { 80 return this.bytes; 81 } 82 } 83 | Popular Tags |