- if (e instanceof LongEnt) {
- index++;
- continue;
- }
- if (!(e instanceof CPRefEnt)) continue;
- CPRefEnt ce = (CPRefEnt) e;
- if (e1s[i] == 0 || e1s[i] >= usedSlots) throw new ClassFile.ClassReadExn("invalid cp index");
- ce.e1 = entriesByIndex[e1s[i]];
- if (ce.e1 == null) throw new ClassFile.ClassReadExn("invalid cp index");
- if (ce.tag != 7 && ce.tag != 8) {
- if (e2s[i] == 0 || e2s[i] >= usedSlots) throw new ClassFile.ClassReadExn("invalid cp index");
- ce.e2 = entriesByIndex[e2s[i]];
- if (ce.e2 == null) throw new ClassFile.ClassReadExn("invalid cp index");
- }
- switch(ce.tag) {
- case 7:
- case 8:
- if (!(ce.e1 instanceof Utf8Ent)) throw new ClassFile.ClassReadExn("expected a utf8 ent");
- break;
- case 9:
- case 10:
- case 11:
- if (!(ce.e1 instanceof CPRefEnt) || ((CPRefEnt)ce.e1).tag != 7)
- throw new ClassFile.ClassReadExn("expected a type ent");
- if (!(ce.e2 instanceof CPRefEnt) || ((CPRefEnt)ce.e2).tag != 12)
- throw new ClassFile.ClassReadExn("expected a name and type ent");
- break;
- case 12:
- if (!(ce.e1 instanceof Utf8Ent)) throw new ClassFile.ClassReadExn("expected a utf8 ent");
- if (!(ce.e2 instanceof Utf8Ent)) throw new ClassFile.ClassReadExn("expected a utf8 ent");
- break;
+ boolean isMem = e instanceof MemberEnt;
+ boolean isString = e instanceof StringLitEnt;
+ boolean isClass = e instanceof ClassEnt;
+ boolean isNameAndType = e instanceof NameAndTypeEnt;
+ if (isMem || isClass || isString || isNameAndType) {
+ if (e1s[i] == 0 || e1s[i] >= usedSlots) throw new ClassFile.ClassReadExn("invalid cp index");
+ Ent e1 = entriesByIndex[e1s[i]];
+ if(e1 == null) throw new ClassFile.ClassReadExn("invalid cp index");
+ if(isClass) {
+ if(!(e1 instanceof Utf8Ent)) throw new ClassFile.ClassReadExn("expected a uft8ent");
+ ((ClassEnt)e).utf8 = (Utf8Ent) e1;
+ } else if(isString) {
+ if(!(e1 instanceof Utf8Ent)) throw new ClassFile.ClassReadExn("expected a uft8ent");
+ ((StringLitEnt)e).utf8 = (Utf8Ent) e1;
+ } else if(isMem || isNameAndType) {
+ if (e2s[i] == 0 || e2s[i] >= usedSlots) throw new ClassFile.ClassReadExn("invalid cp index");
+ Ent e2 = entriesByIndex[e2s[i]];
+ if(isMem) {
+ if(!(e1 instanceof ClassEnt)) throw new ClassFile.ClassReadExn("expected a classent");
+ if(!(e2 instanceof NameAndTypeEnt)) throw new ClassFile.ClassReadExn("expected a nameandtypeent, not " + e2);
+ MemberEnt me = (MemberEnt) e;
+ me.klass = (ClassEnt) e1;
+ me.member = (NameAndTypeEnt) e2;
+ } else if(isNameAndType) {
+ if(!(e1 instanceof Utf8Ent)) throw new ClassFile.ClassReadExn("expected a uft8ent");
+ if(!(e2 instanceof Utf8Ent)) throw new ClassFile.ClassReadExn("expected a uft8ent");
+ NameAndTypeEnt nte = (NameAndTypeEnt) e;
+ nte.name = (Utf8Ent) e1;
+ nte.type = (Utf8Ent) e2;
+ }
+ }