// Source File Name:   ClassFile.java

package mhc.compiler;

import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Vector;
import mhc.io;

// Referenced classes of package mhc.compiler:
//            cp_info, field_info, method_info, attribute_info, 
//            SourceFile_attribute, CONSTANT_Utf8_info, CONSTANT_NameAndType_info, CONSTANT_Class_info, 
//            CONSTANT_Fieldref_info, CONSTANT_Methodref_info, CONSTANT_InterfaceMethodref_info, CONSTANT_Integer_info, 
//            CONSTANT_Float_info, CONSTANT_Double_info, CONSTANT_Long_info, CONSTANT_String_info, 
//            ConstantValue_attribute, LineNumberTable_attribute, LocalVariableTable_attribute, Code_attribute, 
//            Exceptions_attribute

class ClassFile {

    String name;
    RandomAccessFile out_handle;
    String out_name;
    int magic;
    short minor_version;
    short major_version;
    short constant_pool_count;
    cp_info constant_pool[];
    short access_flags;
    short this_class;
    short super_class;
    short interfaces_count;
    short interfaces[];
    short fields_count;
    field_info fields[];
    short methods_count;
    method_info methods[];
    short attributes_count;
    attribute_info attributes[];
    static final short ACC_PUBLIC = 1;
    static final short ACC_PRIVATE = 2;
    static final short ACC_PROTECTED = 4;
    static final short ACC_STATIC = 8;
    static final short ACC_FINAL = 16;
    static final short ACC_SYNCHRONIZED = 32;
    static final short ACC_SUPER = 32;
    static final short ACC_VOLATILE = 64;
    static final short ACC_TRANSIENT = 128;
    static final short ACC_NATIVE = 256;
    static final short ACC_INTERFACE = 512;
    static final short ACC_ABSTRACT = 1024;
    static final int MAX_STACK = 256;
    static final short INCR_CONSTANT_POOL = 1024;
    static final short INCR_FIELDS = 32;
    static final short INCR_METHODS = 32;
    static final short INCR_INTERFACES = 8;
    static final short INCR_ATTRIBUTES = 128;
    static final byte OP_bipush = 16;
    static final byte OP_sipush = 17;
    static final byte OP_ldc1 = 18;
    static final byte OP_ldc2 = 19;
    static final byte OP_ldc2w = 20;
    static final byte OP_aconst_null = 1;
    static final byte OP_iconst_m1 = 2;
    static final byte OP_iconst_0 = 3;
    static final byte OP_iconst_1 = 4;
    static final byte OP_iconst_2 = 5;
    static final byte OP_iconst_3 = 6;
    static final byte OP_iconst_4 = 7;
    static final byte OP_iconst_5 = 8;
    static final byte OP_lconst_0 = 9;
    static final byte OP_lconst_1 = 10;
    static final byte OP_fconst_0 = 11;
    static final byte OP_fconst_1 = 12;
    static final byte OP_fconst_2 = 13;
    static final byte OP_dconst_0 = 14;
    static final byte OP_dconst_1 = 15;
    static final byte OP_iload = 21;
    static final byte OP_iload_0 = 26;
    static final byte OP_iload_1 = 27;
    static final byte OP_iload_2 = 28;
    static final byte OP_iload_3 = 29;
    static final byte OP_lload = 22;
    static final byte OP_lload_0 = 30;
    static final byte OP_lload_1 = 31;
    static final byte OP_lload_2 = 32;
    static final byte OP_lload_3 = 33;
    static final byte OP_fload = 23;
    static final byte OP_fload_0 = 34;
    static final byte OP_fload_1 = 35;
    static final byte OP_fload_2 = 36;
    static final byte OP_fload_3 = 37;
    static final byte OP_dload = 24;
    static final byte OP_dload_0 = 38;
    static final byte OP_dload_1 = 39;
    static final byte OP_dload_2 = 40;
    static final byte OP_dload_3 = 41;
    static final byte OP_aload = 25;
    static final byte OP_aload_0 = 42;
    static final byte OP_aload_1 = 43;
    static final byte OP_aload_2 = 44;
    static final byte OP_aload_3 = 45;
    static final byte OP_istore = 54;
    static final byte OP_istore_0 = 59;
    static final byte OP_istore_1 = 60;
    static final byte OP_istore_2 = 61;
    static final byte OP_istore_3 = 62;
    static final byte OP_lstore = 55;
    static final byte OP_lstore_0 = 63;
    static final byte OP_lstore_1 = 64;
    static final byte OP_lstore_2 = 65;
    static final byte OP_lstore_3 = 66;
    static final byte OP_fstore = 56;
    static final byte OP_fstore_0 = 67;
    static final byte OP_fstore_1 = 68;
    static final byte OP_fstore_2 = 69;
    static final byte OP_fstore_3 = 70;
    static final byte OP_dstore = 57;
    static final byte OP_dstore_0 = 71;
    static final byte OP_dstore_1 = 72;
    static final byte OP_dstore_2 = 73;
    static final byte OP_dstore_3 = 74;
    static final byte OP_astore = 58;
    static final byte OP_astore_0 = 75;
    static final byte OP_astore_1 = 76;
    static final byte OP_astore_2 = 77;
    static final byte OP_astore_3 = 78;
    static final byte OP_iinc = -124;
    static final byte OP_wide = -60;
    static final byte OP_newarray = -68;
    static final byte OP_anewarray = -67;
    static final byte OP_multianewarray = -59;
    static final byte OP_arraylength = -66;
    static final byte OP_iaload = 46;
    static final byte OP_laload = 47;
    static final byte OP_faload = 48;
    static final byte OP_daload = 49;
    static final byte OP_aaload = 50;
    static final byte OP_baload = 51;
    static final byte OP_caload = 52;
    static final byte OP_saload = 53;
    static final byte OP_iastore = 79;
    static final byte OP_lastore = 80;
    static final byte OP_fastore = 81;
    static final byte OP_dastore = 82;
    static final byte OP_aastore = 83;
    static final byte OP_bastore = 84;
    static final byte OP_castore = 85;
    static final byte OP_sastore = 86;
    static final byte OP_nop = 0;
    static final byte OP_pop = 87;
    static final byte OP_pop2 = 88;
    static final byte OP_dup = 89;
    static final byte OP_dup2 = 92;
    static final byte OP_dup_x1 = 90;
    static final byte OP_dup2_x1 = 93;
    static final byte OP_dup_x2 = 91;
    static final byte OP_dup2_x2 = 94;
    static final byte OP_swap = 95;
    static final byte OP_iadd = 96;
    static final byte OP_ladd = 97;
    static final byte OP_fadd = 98;
    static final byte OP_dadd = 99;
    static final byte OP_isub = 100;
    static final byte OP_lsub = 101;
    static final byte OP_fsub = 102;
    static final byte OP_dsub = 103;
    static final byte OP_imul = 104;
    static final byte OP_lmul = 105;
    static final byte OP_fmul = 106;
    static final byte OP_dmul = 107;
    static final byte OP_idiv = 108;
    static final byte OP_ldiv = 109;
    static final byte OP_fdiv = 110;
    static final byte OP_ddiv = 111;
    static final byte OP_irem = 112;
    static final byte OP_lrem = 113;
    static final byte OP_frem = 114;
    static final byte OP_drem = 115;
    static final byte OP_ineg = 116;
    static final byte OP_lneg = 117;
    static final byte OP_fneg = 118;
    static final byte OP_dneg = 119;
    static final byte OP_ishl = 120;
    static final byte OP_ishr = 122;
    static final byte OP_iushr = 124;
    static final byte OP_lshl = 121;
    static final byte OP_lshr = 123;
    static final byte OP_lushr = 125;
    static final byte OP_iand = 126;
    static final byte OP_land = 127;
    static final byte OP_ior = -128;
    static final byte OP_lor = -127;
    static final byte OP_ixor = -126;
    static final byte OP_lxor = -125;
    static final byte OP_i2l = -123;
    static final byte OP_i2f = -122;
    static final byte OP_i2d = -121;
    static final byte OP_l2i = -120;
    static final byte OP_l2f = -119;
    static final byte OP_l2d = -118;
    static final byte OP_f2i = -117;
    static final byte OP_f2l = -116;
    static final byte OP_f2d = -115;
    static final byte OP_d2i = -114;
    static final byte OP_d2l = -113;
    static final byte OP_d2f = -112;
    static final byte OP_int2byte = -111;
    static final byte OP_int2char = -110;
    static final byte OP_int2short = -109;
    static final byte OP_ifeq = -103;
    static final byte OP_ifnull = -58;
    static final byte OP_iflt = -101;
    static final byte OP_ifle = -98;
    static final byte OP_ifne = -102;
    static final byte OP_ifnonnull = -57;
    static final byte OP_ifgt = -99;
    static final byte OP_ifge = -100;
    static final byte OP_if_icmpeq = -97;
    static final byte OP_if_icmpne = -96;
    static final byte OP_if_icmplt = -95;
    static final byte OP_if_icmpgt = -93;
    static final byte OP_if_icmple = -92;
    static final byte OP_if_icmpge = -94;
    static final byte OP_lcmp = -108;
    static final byte OP_fcmpl = -107;
    static final byte OP_fcmpg = -106;
    static final byte OP_dcmpl = -105;
    static final byte OP_dcmpg = -104;
    static final byte OP_if_acmpeq = -91;
    static final byte OP_if_acmpne = -90;
    static final byte OP_goto = -89;
    static final byte OP_goto_w = -56;
    static final byte OP_jsr = -88;
    static final byte OP_jsr_w = -55;
    static final byte OP_ret = -87;
    static final byte OP_ret_w = -47;
    static final byte OP_ireturn = -84;
    static final byte OP_lreturn = -83;
    static final byte OP_freturn = -82;
    static final byte OP_dreturn = -81;
    static final byte OP_areturn = -80;
    static final byte OP_return = -79;
    static final byte OP_breakpoint = -54;
    static final byte OP_tableswitch = -86;
    static final byte OP_lookupswitch = -85;
    static final byte OP_putfield = -75;
    static final byte OP_getfield = -76;
    static final byte OP_putstatic = -77;
    static final byte OP_getstatic = -78;
    static final byte OP_invokevirtual = -74;
    static final byte OP_invokenonvirtual = -73;
    static final byte OP_invokestatic = -72;
    static final byte OP_invokeinterface = -71;
    static final byte OP_athrow = -65;
    static final byte OP_new = -69;
    static final byte OP_checkcast = -64;
    static final byte OP_instanceof = -63;
    static final byte OP_monitorenter = -62;
    static final byte OP_monitorexit = -61;
    static final byte T_BOOLEAN = 4;
    static final byte T_CHAR = 5;
    static final byte T_FLOAT = 6;
    static final byte T_DOUBLE = 7;
    static final byte T_BYTE = 8;
    static final byte T_SHORT = 9;
    static final byte T_INT = 10;
    static final byte T_LONG = 11;

    public ClassFile(String s, String s1) {
        name = s.replace('/', '.');
        magic = 0xcafebabe;
        minor_version = 3;
        major_version = 45;
        constant_pool_count = 1;
        constant_pool = new cp_info[1024];
        ClassFile _tmp = this;
        access_flags = (short)(0x20 | 1);
        this_class = (short)make_CONSTANT_Class(s.replace('.', '/'));
        super_class = (short)make_CONSTANT_Class("java/lang/Object");
        interfaces = new short[8];
        fields = new field_info[32];
        methods = new method_info[32];
        attributes = new attribute_info[128];
        short word0 = attributes_count;
        attributes_count++;
        attributes[word0] = new SourceFile_attribute(make_CONSTANT_Utf8("SourceFile"), make_CONSTANT_Utf8(s1));
    }

    void write(int i) {
        try {
            out_handle.writeInt(i);
        }
        catch(IOException ioexception) {
            throw new RuntimeException((new StringBuilder()).append("File write error for class ").append(name).toString());
        }
    }

    void write(short word0) {
        try {
            out_handle.writeShort(word0);
        }
        catch(IOException ioexception) {
            throw new RuntimeException((new StringBuilder()).append("File write error for class ").append(name).toString());
        }
    }

    public void write_class(RandomAccessFile randomaccessfile) {
        out_handle = randomaccessfile;
        write(magic);
        write(minor_version);
        write(major_version);
        write(constant_pool_count);
        short word0 = constant_pool_count;
        for(int i = 1; i < word0; i++)
            if(constant_pool[i] != null)
                constant_pool[i].write(randomaccessfile, name);

        write(access_flags);
        write(this_class);
        write(super_class);
        write(interfaces_count);
        word0 = interfaces_count;
        for(int j = 0; j < word0; j++)
            write(interfaces[j]);

        write(fields_count);
        word0 = fields_count;
        for(int k = 0; k < word0; k++)
            fields[k].write(randomaccessfile, name);

        write(methods_count);
        word0 = methods_count;
        for(int l = 0; l < word0; l++)
            methods[l].write(randomaccessfile, name);

        write(attributes_count);
        word0 = attributes_count;
        for(int i1 = 0; i1 < word0; i1++)
            attributes[i1].write(randomaccessfile, name);

    }

    String get_root(String s) {
        int i = s.lastIndexOf('.');
        if(i < 0)
            i = s.lastIndexOf('/');
        return s.substring(i + 1);
    }

    public void write_class(String s) {
        String s1 = get_root(name);
        String s2 = (new StringBuilder()).append(s).append(s1).append(".class").toString();
        RandomAccessFile randomaccessfile = io.open(s2, 612, 384);
        if(randomaccessfile == null)
            throw new RuntimeException((new StringBuilder()).append("File creation error for ").append(s2).toString());
        write_class(randomaccessfile);
        if(io.close(randomaccessfile) < 0)
            throw new RuntimeException((new StringBuilder()).append("File close error for ").append(s2).toString());
        else
            return;
    }

    static void abort() {
        System.runFinalization();
        System.exit(1);
    }

    static String new_string(byte abyte0[], String s) {
        String s1;
        try {
            s1 = new String(abyte0, s);
        }
        catch(UnsupportedEncodingException unsupportedencodingexception) {
            unsupportedencodingexception.printStackTrace();
            s1 = null;
            abort();
        }
        return s1;
    }

    int find_CONSTANT_Utf8(String s) {
        int j = s.length();
        for(int i = 0; i < constant_pool_count; i++) {
            if(constant_pool[i] == null || constant_pool[i].tag != 1)
                continue;
            CONSTANT_Utf8_info constant_utf8_info = (CONSTANT_Utf8_info)constant_pool[i];
            if(constant_utf8_info.length == j && new_string(constant_utf8_info.bytes, "UTF-8").equals(s))
                return i;
        }

        return -1;
    }

    public int make_CONSTANT_Utf8(String s) {
        int i = find_CONSTANT_Utf8(s);
        if(i == -1)
            i = new_CONSTANT_Utf8(s);
        return i;
    }

    void ensure_constant_pool_capacity(int i) {
        if(constant_pool.length < i) {
            cp_info acp_info[] = constant_pool;
            int j = acp_info.length;
            if(j + 1024 >= 32767)
                throw new IndexOutOfBoundsException("Class file constant pool overflow");
            constant_pool = new cp_info[j + 1024];
            System.arraycopy(acp_info, 0, constant_pool, 0, j);
        }
    }

    int new_CONSTANT_Utf8(String s) {
        ensure_constant_pool_capacity(constant_pool_count + 1);
        short word0 = constant_pool_count;
        constant_pool[word0] = new CONSTANT_Utf8_info(s);
        constant_pool_count++;
        return word0;
    }

    int find_CONSTANT_NameAndType(int i, int j) {
        for(int k = 0; k < constant_pool_count; k++) {
            if(constant_pool[k] == null || constant_pool[k].tag != 12)
                continue;
            CONSTANT_NameAndType_info constant_nameandtype_info = (CONSTANT_NameAndType_info)constant_pool[k];
            if(constant_nameandtype_info.name_index == i && constant_nameandtype_info.signature_index == j)
                return k;
        }

        return -1;
    }

    int new_CONSTANT_NameAndType(int i, int j) {
        ensure_constant_pool_capacity(constant_pool_count + 1);
        short word0 = constant_pool_count;
        constant_pool[word0] = new CONSTANT_NameAndType_info(i, j);
        constant_pool_count++;
        return word0;
    }

    int make_CONSTANT_NameAndType(String s, String s1) {
        int j = make_CONSTANT_Utf8(s);
        int k = make_CONSTANT_Utf8(s1);
        int i = find_CONSTANT_NameAndType(j, k);
        if(i == -1)
            i = new_CONSTANT_NameAndType(j, k);
        return i;
    }

    int find_CONSTANT_Class(int i) {
        int k = i;
        if(k >= 0) {
            for(int j = 0; j < constant_pool_count; j++) {
                if(constant_pool[j] == null || constant_pool[j].tag != 7)
                    continue;
                CONSTANT_Class_info constant_class_info = (CONSTANT_Class_info)constant_pool[j];
                if(constant_class_info.name_index == k)
                    return j;
            }

        }
        return -1;
    }

    int new_CONSTANT_Class(int i) {
        int j = i;
        ensure_constant_pool_capacity(constant_pool_count + 1);
        short word0 = constant_pool_count;
        constant_pool[word0] = new CONSTANT_Class_info(j);
        constant_pool_count++;
        return word0;
    }

    public int make_CONSTANT_Class(String s) {
        int j = make_CONSTANT_Utf8(s);
        int i = find_CONSTANT_Class(j);
        if(i == -1)
            i = new_CONSTANT_Class(j);
        return i;
    }

    int find_CONSTANT_Fieldref(int i, int j) {
        for(int k = 0; k < constant_pool_count; k++) {
            if(constant_pool[k] == null || constant_pool[k].tag != 9)
                continue;
            CONSTANT_Fieldref_info constant_fieldref_info = (CONSTANT_Fieldref_info)constant_pool[k];
            if(constant_fieldref_info.class_index == i && constant_fieldref_info.name_and_type_index == j)
                return k;
        }

        return -1;
    }

    int new_CONSTANT_Fieldref(int i, int j) {
        ensure_constant_pool_capacity(constant_pool_count + 1);
        short word0 = constant_pool_count;
        constant_pool[word0] = new CONSTANT_Fieldref_info(i, j);
        constant_pool_count++;
        return word0;
    }

    public int make_CONSTANT_Fieldref(String s, String s1, String s2) {
        int j = make_CONSTANT_Class(s);
        int k = make_CONSTANT_NameAndType(s1, s2);
        int i = find_CONSTANT_Fieldref(j, k);
        if(i == -1)
            i = new_CONSTANT_Fieldref(j, k);
        return i;
    }

    int find_CONSTANT_Methodref(int i, int j) {
        for(int k = 0; k < constant_pool_count; k++) {
            if(constant_pool[k] == null || constant_pool[k].tag != 10)
                continue;
            CONSTANT_Methodref_info constant_methodref_info = (CONSTANT_Methodref_info)constant_pool[k];
            if(constant_methodref_info.class_index == i && constant_methodref_info.name_and_type_index == j)
                return k;
        }

        return -1;
    }

    int new_CONSTANT_Methodref(int i, int j) {
        ensure_constant_pool_capacity(constant_pool_count + 1);
        short word0 = constant_pool_count;
        constant_pool[word0] = new CONSTANT_Methodref_info(i, j);
        constant_pool_count++;
        return word0;
    }

    public int make_CONSTANT_Methodref(String s, String s1, String s2) {
        int j = make_CONSTANT_Class(s);
        int k = make_CONSTANT_NameAndType(s1, s2);
        int i = find_CONSTANT_Methodref(j, k);
        if(i == -1)
            i = new_CONSTANT_Methodref(j, k);
        return i;
    }

    boolean is_CONSTANT_InterfaceMethodref(int i) {
        return i < constant_pool_count && constant_pool[i] != null && constant_pool[i].tag == 11;
    }

    int find_CONSTANT_InterfaceMethodref(int i, int j) {
        for(int k = 0; k < constant_pool_count; k++) {
            if(constant_pool[k] == null || constant_pool[k].tag != 11)
                continue;
            CONSTANT_InterfaceMethodref_info constant_interfacemethodref_info = (CONSTANT_InterfaceMethodref_info)constant_pool[k];
            if(constant_interfacemethodref_info.class_index == i && constant_interfacemethodref_info.name_and_type_index == j)
                return k;
        }

        return -1;
    }

    int new_CONSTANT_InterfaceMethodref(int i, int j) {
        ensure_constant_pool_capacity(constant_pool_count + 1);
        short word0 = constant_pool_count;
        constant_pool[word0] = new CONSTANT_InterfaceMethodref_info(i, j);
        constant_pool_count++;
        return word0;
    }

    public int make_CONSTANT_InterfaceMethodref(String s, String s1, String s2) {
        int j = make_CONSTANT_Class(s);
        int k = make_CONSTANT_NameAndType(s1, s2);
        int i = find_CONSTANT_InterfaceMethodref(j, k);
        if(i == -1)
            i = new_CONSTANT_InterfaceMethodref(j, k);
        return i;
    }

    int find_CONSTANT_Integer(int i) {
        for(int j = 0; j < constant_pool_count; j++) {
            if(constant_pool[j] == null || constant_pool[j].tag != 3)
                continue;
            CONSTANT_Integer_info constant_integer_info = (CONSTANT_Integer_info)constant_pool[j];
            if(constant_integer_info.bytes == i)
                return j;
        }

        return -1;
    }

    int new_CONSTANT_Integer(int i) {
        ensure_constant_pool_capacity(constant_pool_count + 1);
        short word0 = constant_pool_count;
        constant_pool[word0] = new CONSTANT_Integer_info(i);
        constant_pool_count++;
        return word0;
    }

    public int make_CONSTANT_Integer(int i) {
        int j = find_CONSTANT_Integer(i);
        if(j == -1)
            j = new_CONSTANT_Integer(i);
        return j;
    }

    int find_CONSTANT_Float(int i) {
        for(int j = 0; j < constant_pool_count; j++) {
            if(constant_pool[j] == null || constant_pool[j].tag != 4)
                continue;
            CONSTANT_Float_info constant_float_info = (CONSTANT_Float_info)constant_pool[j];
            if(constant_float_info.bytes == i)
                return j;
        }

        return -1;
    }

    int new_CONSTANT_Float(int i) {
        ensure_constant_pool_capacity(constant_pool_count + 1);
        short word0 = constant_pool_count;
        constant_pool[word0] = new CONSTANT_Float_info(i);
        constant_pool_count++;
        return word0;
    }

    public int make_CONSTANT_Float(float f) {
        int j = Float.floatToIntBits(f);
        int i = find_CONSTANT_Float(j);
        if(i == -1)
            i = new_CONSTANT_Float(j);
        return i;
    }

    int find_CONSTANT_Double(long l) {
        for(int i = 0; i < constant_pool_count; i++) {
            if(constant_pool[i] == null || constant_pool[i].tag != 6)
                continue;
            CONSTANT_Double_info constant_double_info = (CONSTANT_Double_info)constant_pool[i];
            if(constant_double_info.high_bytes == (int)(l >>> 32) && constant_double_info.low_bytes == (int)l)
                return i;
        }

        return -1;
    }

    int new_CONSTANT_Double(long l) {
        ensure_constant_pool_capacity(constant_pool_count + 2);
        short word0 = constant_pool_count;
        constant_pool[word0] = new CONSTANT_Double_info(l);
        constant_pool_count += 2;
        return word0;
    }

    public int make_CONSTANT_Double(double d) {
        long l = Double.doubleToLongBits(d);
        int i = find_CONSTANT_Double(l);
        if(i == -1)
            i = new_CONSTANT_Double(l);
        return i;
    }

    int find_CONSTANT_Long(long l) {
        for(int i = 0; i < constant_pool_count; i++) {
            if(constant_pool[i] == null || constant_pool[i].tag != 5)
                continue;
            CONSTANT_Long_info constant_long_info = (CONSTANT_Long_info)constant_pool[i];
            if(constant_long_info.high_bytes == (int)(l >>> 32) && constant_long_info.low_bytes == (int)l)
                return i;
        }

        return -1;
    }

    int new_CONSTANT_Long(long l) {
        ensure_constant_pool_capacity(constant_pool_count + 2);
        short word0 = constant_pool_count;
        constant_pool[word0] = new CONSTANT_Long_info(l);
        constant_pool_count += 2;
        return word0;
    }

    public int make_CONSTANT_Long(long l) {
        int i = find_CONSTANT_Long(l);
        if(i == -1)
            i = new_CONSTANT_Long(l);
        return i;
    }

    int find_CONSTANT_String(int i) {
        int k = i;
        if(k >= 0) {
            for(int j = 0; j < constant_pool_count; j++) {
                if(constant_pool[j] == null || constant_pool[j].tag != 8)
                    continue;
                CONSTANT_String_info constant_string_info = (CONSTANT_String_info)constant_pool[j];
                if(constant_string_info.string_index == (short)k)
                    return j;
            }

        }
        return -1;
    }

    int new_CONSTANT_String(int i) {
        int j = i;
        ensure_constant_pool_capacity(constant_pool_count + 1);
        short word0 = constant_pool_count;
        constant_pool[word0] = new CONSTANT_String_info(j);
        constant_pool_count++;
        return word0;
    }

    public int make_CONSTANT_String(String s) {
        int j = make_CONSTANT_Utf8(s);
        int i = find_CONSTANT_String(j);
        if(i == -1)
            i = new_CONSTANT_String(j);
        return i;
    }

    public boolean is_CONSTANT_Methodref(int i, String s) {
        if(constant_pool[i] instanceof CONSTANT_Methodref_info) {
            CONSTANT_Methodref_info constant_methodref_info = (CONSTANT_Methodref_info)constant_pool[i];
            i = constant_methodref_info.name_and_type_index;
            CONSTANT_NameAndType_info constant_nameandtype_info = (CONSTANT_NameAndType_info)constant_pool[i];
            i = constant_nameandtype_info.name_index;
            CONSTANT_Utf8_info constant_utf8_info = (CONSTANT_Utf8_info)constant_pool[i];
            if(constant_utf8_info.length == s.length()) {
                short word0 = constant_utf8_info.length;
                for(i = 0; i < word0 && (char)constant_utf8_info.bytes[i] == s.charAt(i); i++);
                if(i >= word0)
                    return true;
            }
        }
        return false;
    }

    public String get_class_id_of_CONSTANT_Methodref(int i) {
        CONSTANT_Methodref_info constant_methodref_info = (CONSTANT_Methodref_info)constant_pool[i];
        i = constant_methodref_info.class_index;
        CONSTANT_Class_info constant_class_info = (CONSTANT_Class_info)constant_pool[i];
        i = constant_class_info.name_index;
        CONSTANT_Utf8_info constant_utf8_info = (CONSTANT_Utf8_info)constant_pool[i];
        StringBuffer stringbuffer = new StringBuffer();
        short word0 = constant_utf8_info.length;
        for(i = 0; i < word0; i++)
            stringbuffer.append((char)constant_utf8_info.bytes[i]);

        return stringbuffer.toString();
    }

    public String get_signature_of_CONSTANT_Methodref(int i) {
        CONSTANT_Methodref_info constant_methodref_info = (CONSTANT_Methodref_info)constant_pool[i];
        i = constant_methodref_info.name_and_type_index;
        CONSTANT_NameAndType_info constant_nameandtype_info = (CONSTANT_NameAndType_info)constant_pool[i];
        i = constant_nameandtype_info.signature_index;
        CONSTANT_Utf8_info constant_utf8_info = (CONSTANT_Utf8_info)constant_pool[i];
        StringBuffer stringbuffer = new StringBuffer();
        short word0 = constant_utf8_info.length;
        for(i = 0; i < word0; i++)
            stringbuffer.append((char)constant_utf8_info.bytes[i]);

        return stringbuffer.toString();
    }

    String class_index_to_String(int i) {
        CONSTANT_Class_info constant_class_info = (CONSTANT_Class_info)constant_pool[i];
        CONSTANT_Utf8_info constant_utf8_info = (CONSTANT_Utf8_info)constant_pool[constant_class_info.name_index];
        return (new String(constant_utf8_info.bytes)).replace('/', '.');
    }

    String nameof_CONSTANT_NameAndType_info(CONSTANT_NameAndType_info constant_nameandtype_info) {
        CONSTANT_Utf8_info constant_utf8_info = (CONSTANT_Utf8_info)constant_pool[constant_nameandtype_info.name_index];
        return (new String(constant_utf8_info.bytes)).replace('/', '.');
    }

    String nameof_CONSTANT_Fieldref_info(CONSTANT_Fieldref_info constant_fieldref_info) {
        CONSTANT_NameAndType_info constant_nameandtype_info = (CONSTANT_NameAndType_info)constant_pool[constant_fieldref_info.name_and_type_index];
        return nameof_CONSTANT_NameAndType_info(constant_nameandtype_info);
    }

    public Object const_val_for_CONSTANT_Fieldref(int i) {
        CONSTANT_Fieldref_info constant_fieldref_info = (CONSTANT_Fieldref_info)constant_pool[i];
        String s = class_index_to_String(constant_fieldref_info.class_index);
        Class class1;
        try {
            class1 = Class.forName(s);
        }
        catch(ClassNotFoundException classnotfoundexception) {
            class1 = null;
        }
        if(class1 == null)
            return null;
        String s1 = nameof_CONSTANT_Fieldref_info(constant_fieldref_info);
        Field field;
        try {
            field = class1.getDeclaredField(s1);
        }
        catch(NoSuchFieldException nosuchfieldexception) {
            field = null;
        }
        if(field == null)
            return null;
        int j = field.getModifiers();
        if(!Modifier.isFinal(j))
            return null;
        if(!Modifier.isStatic(j))
            return null;
        Object obj;
        try {
            obj = field.get(null);
        }
        catch(IllegalAccessException illegalaccessexception) {
            obj = null;
        }
        return obj;
    }

    void ensure_fields_capacity(int i) {
        if(fields.length < i) {
            field_info afield_info[] = fields;
            int j = afield_info.length;
            if(j + 32 >= 32767)
                throw new IndexOutOfBoundsException("Class file fields-array overflow");
            fields = new field_info[j + 32];
            System.arraycopy(afield_info, 0, fields, 0, j);
        }
    }

    void ensure_attributes_capacity(int i) {
        if(attributes.length < i) {
            attribute_info aattribute_info[] = attributes;
            int j = aattribute_info.length;
            if(j + 128 >= 32767)
                throw new IndexOutOfBoundsException("Class file attributes-array overflow");
            attributes = new attribute_info[j + 128];
            System.arraycopy(aattribute_info, 0, attributes, 0, j);
        }
    }

    public void add_field_member(int i, String s, String s1, Object obj) {
        ensure_fields_capacity(fields_count + 1);
        ConstantValue_attribute constantvalue_attribute = null;
        if(obj != null)
            if(obj instanceof Integer)
                constantvalue_attribute = new ConstantValue_attribute(make_CONSTANT_Utf8("ConstantValue"), make_CONSTANT_Integer(((Integer)obj).intValue()));
            else
            if(obj instanceof Long)
                constantvalue_attribute = new ConstantValue_attribute(make_CONSTANT_Utf8("ConstantValue"), make_CONSTANT_Long(((Long)obj).longValue()));
            else
            if(obj instanceof Float)
                constantvalue_attribute = new ConstantValue_attribute(make_CONSTANT_Utf8("ConstantValue"), make_CONSTANT_Float(((Float)obj).floatValue()));
            else
            if(obj instanceof Double)
                constantvalue_attribute = new ConstantValue_attribute(make_CONSTANT_Utf8("ConstantValue"), make_CONSTANT_Double(((Double)obj).doubleValue()));
        fields[fields_count] = new field_info(i, make_CONSTANT_Utf8(s), make_CONSTANT_Utf8(s1), constantvalue_attribute);
        fields_count++;
    }

    void ensure_methods_capacity(int i) {
        if(methods.length < i) {
            method_info amethod_info[] = methods;
            int j = amethod_info.length;
            if(j + 32 >= 32767)
                throw new IndexOutOfBoundsException("Class file methods-array overflow");
            methods = new method_info[j + 32];
            System.arraycopy(amethod_info, 0, methods, 0, j);
        }
    }

    public void add_method_member(int i, String s, String s1, byte abyte0[], int j, int k, Vector vector, 
            Vector vector1, Vector vector2) {
        LineNumberTable_attribute linenumbertable_attribute = null;
        LocalVariableTable_attribute localvariabletable_attribute = null;
        ensure_methods_capacity(methods_count + 1);
        if(vector != null)
            linenumbertable_attribute = new LineNumberTable_attribute(vector, make_CONSTANT_Utf8("LineNumberTable"));
        if(vector1 != null)
            localvariabletable_attribute = new LocalVariableTable_attribute(vector1, make_CONSTANT_Utf8("LocalVariableTable"), abyte0.length);
        Code_attribute code_attribute = new Code_attribute(make_CONSTANT_Utf8("Code"), j, k, abyte0, vector2, linenumbertable_attribute, localvariabletable_attribute);
        methods[methods_count] = new method_info(i, make_CONSTANT_Utf8(s), make_CONSTANT_Utf8(s1), code_attribute);
        methods_count++;
    }

    public void add_method_member(int i, String s, String s1, byte abyte0[], int j, int k, Vector vector, 
            Vector vector1, Vector vector2, int ai[]) {
        add_method_member(i, s, s1, abyte0, j, k, vector, vector1, vector2);
        if(ai == null)
            return;
        method_info method_info1 = methods[methods_count - 1];
        int i1 = method_info1.attributes.length;
        attribute_info aattribute_info[] = new attribute_info[i1 + 1];
        for(int l = 0; l < i1; l++)
            aattribute_info[l] = method_info1.attributes[l];

        aattribute_info[i1] = new Exceptions_attribute(make_CONSTANT_Utf8("Exceptions"), ai);
        method_info1.attributes = aattribute_info;
        method_info1.attributes_count = (short)aattribute_info.length;
    }

    public void add_method_member(int i, String s, String s1, byte abyte0[], int j, int k) {
        add_method_member(i, s, s1, abyte0, j, k, null, null, null);
    }

    void ensure_interfaces_capacity(int i) {
        if(interfaces.length < i) {
            short aword0[] = interfaces;
            int j = aword0.length;
            if(j + 8 >= 32767)
                throw new IndexOutOfBoundsException("Class file interfaces-array overflow");
            interfaces = new short[j + 8];
            System.arraycopy(aword0, 0, interfaces, 0, j);
        }
    }

    public void append_interface_list(String s) {
        ensure_interfaces_capacity(interfaces_count + 1);
        interfaces[interfaces_count] = (short)make_CONSTANT_Class(s.replace('.', '/'));
        interfaces_count++;
    }

    public void add_super_class(String s) {
        super_class = (short)make_CONSTANT_Class(s);
    }

    public int stack_size_of_CONSTANT_Fieldref(int i) {
        cp_info cp_info1 = constant_pool[i];
        i = ((CONSTANT_Fieldref_info)cp_info1).name_and_type_index;
        cp_info1 = constant_pool[i];
        i = ((CONSTANT_NameAndType_info)cp_info1).signature_index;
        cp_info1 = constant_pool[i];
        switch(((CONSTANT_Utf8_info)cp_info1).bytes[0]) {
        case 68: // 'D'
        case 74: // 'J'
            return 2;
        }
        return 1;
    }

    public int stack_size_of_CONSTANT_Methodref(int i) {
        boolean flag = true;
        cp_info cp_info1 = constant_pool[i];
        i = ((CONSTANT_Methodref_info)cp_info1).name_and_type_index;
        cp_info1 = constant_pool[i];
        i = ((CONSTANT_NameAndType_info)cp_info1).signature_index;
        cp_info1 = constant_pool[i];
        short word0 = ((CONSTANT_Utf8_info)cp_info1).length;
        int j = 0;
        int k = 0;
        while(j < word0)  {
            char c = (char)((CONSTANT_Utf8_info)cp_info1).bytes[j];
            if(c == '(')
                j++;
            else
            if(c == ')') {
                flag = false;
                j++;
            } else
            if(c == 'V') {
                j++;
            } else {
                if(c == 'J' || c == 'D')
                    k += flag ? 2 : -2;
                else
                if(c == 'L') {
                    k += flag ? 1 : -1;
                    j++;
                    do {
                        if(j >= word0)
                            break;
                        c = (char)((CONSTANT_Utf8_info)cp_info1).bytes[j];
                        if(c == ';')
                            break;
                        j++;
                    } while(true);
                } else
                if(c == '[') {
                    k += flag ? 1 : -1;
                    do {
                        if(j >= word0)
                            break;
                        c = (char)((CONSTANT_Utf8_info)cp_info1).bytes[j];
                        if(c != '[' && (c < '0' || c > '9'))
                            break;
                        j++;
                    } while(true);
                    if(c == 'L') {
                        j++;
                        do {
                            if(j >= word0)
                                break;
                            char c1 = (char)((CONSTANT_Utf8_info)cp_info1).bytes[j];
                            if(c1 == ';')
                                break;
                            j++;
                        } while(true);
                    }
                } else {
                    k += flag ? 1 : -1;
                }
                j++;
            }
        }
        return k;
    }

    public int stack_size_of_CONSTANT_InterfaceMethodref(int i) {
        boolean flag = true;
        cp_info cp_info1 = constant_pool[i];
        i = ((CONSTANT_InterfaceMethodref_info)cp_info1).name_and_type_index;
        cp_info1 = constant_pool[i];
        i = ((CONSTANT_NameAndType_info)cp_info1).signature_index;
        cp_info1 = constant_pool[i];
        short word0 = ((CONSTANT_Utf8_info)cp_info1).length;
        int j = 0;
        int k = 0;
        while(j < word0)  {
            char c = (char)((CONSTANT_Utf8_info)cp_info1).bytes[j];
            if(c == '(')
                j++;
            else
            if(c == ')') {
                flag = false;
                j++;
            } else {
                if(c == 'J' || c == 'D')
                    k += flag ? 2 : -2;
                else
                if(c == 'L') {
                    k += flag ? 1 : -1;
                    j++;
                    do {
                        if(j >= word0)
                            break;
                        c = (char)((CONSTANT_Utf8_info)cp_info1).bytes[j];
                        if(c == ';')
                            break;
                        j++;
                    } while(true);
                } else
                if(c == '[') {
                    k += flag ? 1 : -1;
                    do {
                        if(j >= word0)
                            break;
                        c = (char)((CONSTANT_Utf8_info)cp_info1).bytes[j];
                        if(c != '[' && (c < '0' || c > '9'))
                            break;
                        j++;
                    } while(true);
                    if(c == 'L') {
                        j++;
                        do {
                            if(j >= word0)
                                break;
                            char c1 = (char)((CONSTANT_Utf8_info)cp_info1).bytes[j];
                            if(c1 == ';')
                                break;
                            j++;
                        } while(true);
                    }
                } else {
                    k += flag ? 1 : -1;
                }
                j++;
            }
        }
        return k;
    }
}
