1 15 16 package javassist.bytecode; 17 18 21 public class ByteArray { 22 25 public static int readU16bit(byte[] code, int index) { 26 return ((code[index] & 0xff) << 8) | (code[index + 1] & 0xff); 27 } 28 29 32 public static int readS16bit(byte[] code, int index) { 33 return (code[index] << 8) | (code[index + 1] & 0xff); 34 } 35 36 39 public static void write16bit(int value, byte[] code, int index) { 40 code[index] = (byte)(value >>> 8); 41 code[index + 1] = (byte)value; 42 } 43 44 47 public static int read32bit(byte[] code, int index) { 48 return (code[index] << 24) | ((code[index + 1] & 0xff) << 16) 49 | ((code[index + 2] & 0xff) << 8) | (code[index + 3] & 0xff); 50 } 51 52 55 public static void write32bit(int value, byte[] code, int index) { 56 code[index] = (byte)(value >>> 24); 57 code[index + 1] = (byte)(value >>> 16); 58 code[index + 2] = (byte)(value >>> 8); 59 code[index + 3] = (byte)value; 60 } 61 62 70 static void copy32bit(byte[] src, int isrc, byte[] dest, int idest) { 71 dest[idest] = src[isrc]; 72 dest[idest + 1] = src[isrc + 1]; 73 dest[idest + 2] = src[isrc + 2]; 74 dest[idest + 3] = src[isrc + 3]; 75 } 76 } 77 | Popular Tags |