ConstantPool cp = ConstantPool.readFrom(din);
Modifiers modifiers = Modifiers.getInstance(din.readUnsignedShort())
.toSynchronized(false);
int index = din.readUnsignedShort();
ConstantClassInfo thisClass = (ConstantClassInfo)cp.getConstant(index);
index = din.readUnsignedShort();
ConstantClassInfo superClass = null;
if (index > 0) {
superClass = (ConstantClassInfo)cp.getConstant(index);
}
ClassFile cf = new ClassFile(cp, modifiers, thisClass, superClass, outerClass);
cf.setVersion(major, minor);
loadedClassFiles.put(cf.getClassName(), cf);
// Read interfaces.
int size = din.readUnsignedShort();
for (int i=0; i<size; i++) {
index = din.readUnsignedShort();
ConstantClassInfo info = (ConstantClassInfo)cp.getConstant(index);
cf.addInterface(info.getType().getRootName());
}
// Read fields.
size = din.readUnsignedShort();
for (int i=0; i<size; i++) {
cf.mFields.add(FieldInfo.readFrom(cf, din, attrFactory));
}
// Read methods.
size = din.readUnsignedShort();
for (int i=0; i<size; i++) {
cf.mMethods.add(MethodInfo.readFrom(cf, din, attrFactory));
}
// Read attributes.
size = din.readUnsignedShort();
for (int i=0; i<size; i++) {
Attribute attr = Attribute.readFrom(cp, din, attrFactory);
cf.addAttribute(attr);
if (attr instanceof InnerClassesAttr) {
cf.mInnerClassesAttr = (InnerClassesAttr)attr;
}
}
// Load inner and outer classes.
if (cf.mInnerClassesAttr != null && loader != null) {
InnerClassesAttr.Info[] infos = cf.mInnerClassesAttr.getInnerClassesInfo();
for (int i=0; i<infos.length; i++) {
InnerClassesAttr.Info info = infos[i];
if (thisClass.equals(info.getInnerClass())) {
// This class is an inner class.
if (info.getInnerClassName() != null) {
cf.mInnerClassName = info.getInnerClassName().getValue();
}
ConstantClassInfo outer = info.getOuterClass();
if (cf.mOuterClass == null && outer != null) {
cf.mOuterClass = readOuterClass
(outer, loader, attrFactory, loadedClassFiles);
}
Modifiers innerFlags = info.getModifiers();
cf.mModifiers = cf.mModifiers
.toStatic(innerFlags.isStatic())
.toPrivate(innerFlags.isPrivate())
.toProtected(innerFlags.isProtected())
.toPublic(innerFlags.isPublic());
} else if (info.getOuterClass() == null ||
thisClass.equals(info.getOuterClass())) {
// This class is an outer class.
ConstantClassInfo inner = info.getInnerClass();
if (inner != null) {
ClassFile innerClass = readInnerClass
(inner, loader, attrFactory, loadedClassFiles, cf);
if (innerClass != null) {