public void newarray(Class<?> arrayType) {
        assertTypeOnStack(StackEntryType.INT, "newarray requires int on stack");
        int type = 0;
        String desc;
        if (arrayType == boolean.class) {
            type = Opcode.T_BOOLEAN;
            desc = "[Z";
        } else if (arrayType == char.class) {
            type = Opcode.T_CHAR;
            desc = "[C";
        } else if (arrayType == float.class) {
            type = Opcode.T_FLOAT;
            desc = "[F";
        } else if (arrayType == double.class) {
            type = Opcode.T_DOUBLE;
            desc = "[D";
        } else if (arrayType == byte.class) {
            type = Opcode.T_BYTE;
            desc = "[B";
        } else if (arrayType == short.class) {
            type = Opcode.T_SHORT;
            desc="[S";
        } else if (arrayType == int.class) {
            type = Opcode.T_INT;
            desc = "[I";
        } else if (arrayType == long.class) {
            type = Opcode.T_LONG;
            desc ="[J";
        } else {
            throw new InvalidBytecodeException("Class " + arrayType + " is not a primitive type");
        }
        writeByte(Opcode.NEWARRAY);
        writeByte(type);
        currentOffset+=2;
        advanceFrame(currentFrame.replace(desc));
    }