// Path: src/main/java/org/apache/jdbm/Serialization.java
// static class FastArrayList<K> {
// 
//     private int size = 0;
//     private K[] elementData = (K[]) new Object[8];
// 
//     K get(int index) {
//         if (index >= size) throw new IndexOutOfBoundsException();
//         return elementData[index];
//     }
// 
//     void add(K o) {
//         if (elementData.length == size) {
//             //grow array if necessary
//             elementData = Arrays.copyOf(elementData, elementData.length * 2);
//         }
// 
//         elementData[size] = o;
//         size++;
//     }
// 
//     int size() {
//         return size;
//     }
// 
// 
//     /**
//      * This method is reason why ArrayList is not used.
//      * Search an item in list and returns its index.
//      * It uses identity rather than 'equalsTo'
//      * One could argue that TreeMap should be used instead,
//      * but we do not expect large object trees.
//      * This search is VERY FAST compared to Maps, it does not allocate
//      * new instances or uses method calls.
//      *
//      * @param obj
//      * @return index of object in list or -1 if not found
//      */
//     int identityIndexOf(Object obj) {
//         for (int i = 0; i < size; i++) {
//             if (obj == elementData[i])
//                 return i;
//         }
//         return -1;
//     }
// 
// }


import org.apache.jdbm.Serialization.FastArrayList;
import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
            return;

        ObjectStreamField[] streamFields = getFields(clazz);
        FieldInfo[] fields = new FieldInfo[streamFields.length];
        for (int i = 0; i < fields.length; i++) {
            ObjectStreamField sf = streamFields[i];
            fields[i] = new FieldInfo(sf, clazz);
        }

        ClassInfo i = new ClassInfo(clazz.getName(), fields,clazz.isEnum(), Externalizable.class.isAssignableFrom(clazz));
        class2classId.put(clazz, registered.size());
        classId2class.put(registered.size(), clazz);
        registered.add(i);


        if (db != null)
            db.update(serialClassInfoRecid, (Serialization) this, db.defaultSerializationSerializer);

    }

    private ObjectStreamField[] getFields(Class clazz) {
    	ObjectStreamField[] fields = null;
    	ClassInfo classInfo = null;
    	Integer classId = class2classId.get(clazz);
		if (classId != null) {
			classInfo = registered.get(classId);
			fields = classInfo.getObjectStreamFields();
		}
		if (fields == null) {
			ObjectStreamClass streamClass = ObjectStreamClass.lookup(clazz);
// Path: src/main/java/org/apache/jdbm/Serialization.java
// static class FastArrayList<K> {
// 
//     private int size = 0;
//     private K[] elementData = (K[]) new Object[8];
// 
//     K get(int index) {
//         if (index >= size) throw new IndexOutOfBoundsException();
//         return elementData[index];
//     }
// 
//     void add(K o) {
//         if (elementData.length == size) {
//             //grow array if necessary
//             elementData = Arrays.copyOf(elementData, elementData.length * 2);
//         }
// 
//         elementData[size] = o;
//         size++;
//     }
// 
//     int size() {
//         return size;
//     }
// 
// 
//     /**
//      * This method is reason why ArrayList is not used.
//      * Search an item in list and returns its index.
//      * It uses identity rather than 'equalsTo'
//      * One could argue that TreeMap should be used instead,
//      * but we do not expect large object trees.
//      * This search is VERY FAST compared to Maps, it does not allocate
//      * new instances or uses method calls.
//      *
//      * @param obj
//      * @return index of object in list or -1 if not found
//      */
//     int identityIndexOf(Object obj) {
//         for (int i = 0; i < size; i++) {
//             if (obj == elementData[i])
//                 return i;
//         }
//         return -1;
//     }
// 
// }


// Path: src/main/java/org/apache/jdbm/SerialClassInfo.java
import org.apache.jdbm.Serialization.FastArrayList;
import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

            return;

        ObjectStreamField[] streamFields = getFields(clazz);
        FieldInfo[] fields = new FieldInfo[streamFields.length];
        for (int i = 0; i < fields.length; i++) {
            ObjectStreamField sf = streamFields[i];
            fields[i] = new FieldInfo(sf, clazz);
        }

        ClassInfo i = new ClassInfo(clazz.getName(), fields,clazz.isEnum(), Externalizable.class.isAssignableFrom(clazz));
        class2classId.put(clazz, registered.size());
        classId2class.put(registered.size(), clazz);
        registered.add(i);


        if (db != null)
            db.update(serialClassInfoRecid, (Serialization) this, db.defaultSerializationSerializer);

    }

    private ObjectStreamField[] getFields(Class clazz) {
    	ObjectStreamField[] fields = null;
    	ClassInfo classInfo = null;
    	Integer classId = class2classId.get(clazz);
		if (classId != null) {
			classInfo = registered.get(classId);
			fields = classInfo.getObjectStreamFields();
		}
		if (fields == null) {
			ObjectStreamClass streamClass = ObjectStreamClass.lookup(clazz);
			FastArrayList<ObjectStreamField> fieldsList = new FastArrayList<ObjectStreamField>();