package sds.classfile.bytecode;

import java.io.IOException;
import java.io.RandomAccessFile;

/**
 *
 * @author inagaki
 */
public class TableSwitch extends SwitchOpcode {

	int[] jumpOffsets;

	TableSwitch(int pc) {
		super(MnemonicTable.tableswitch, pc);
	}

	@Override
	public void read(RandomAccessFile raf) throws IOException {
		super.read(raf);
		// low, low + n - 1
		this.jumpOffsets = new int[raf.readInt() - raf.readInt() + 1];
		for(int i = 0; i < jumpOffsets.length; i++) {
			jumpOffsets[i] = raf.readInt();
		}
	}

	public int[] getJumpOffsets() {
		return jumpOffsets;
	}
}

@@ -352,27 +352,60 @@
 ;%0A%09%09
-//
+int
  low
-, low + n - 1
+ = raf.readInt();%0A%09%09int high = raf.readInt();
 %0A%09%09t
@@ -434,37 +434,18 @@
 int%5B
-raf.readInt() - raf.readInt()
+high - low
  + 1

modify bug which 'NegativeArraySizeException' occurs.