/** Print constant value at that index. */ void PrintConstant(int cpx) { if (cpx == 0) { out.print("#0"); return; } byte tag = 0; try { tag = cls.getTag(cpx); } catch (IndexOutOfBoundsException e) { out.print("#" + cpx); return; } switch (tag) { case RuntimeConstants.CONSTANT_METHOD: case RuntimeConstants.CONSTANT_INTERFACEMETHOD: case RuntimeConstants.CONSTANT_FIELD: { // CPX2 x=(CPX2)(cpool[cpx]); CPX2 x = (CPX2) (cls.getCpoolEntry(cpx)); if (x.cpx1 == cls.getthis_cpx()) { // don't print class part for local references cpx = x.cpx2; } } } out.print(cls.TagString(tag) + " " + cls.StringValue(cpx)); }
/** Print ConstantValue attribute information. */ public void printConstantValue(FieldData field) { out.print(" Constant value: "); int cpx = (field.getConstantValueIndex()); byte tag = 0; try { tag = cls.getTag(cpx); } catch (IndexOutOfBoundsException e) { out.print("Error:"); return; } switch (tag) { case RuntimeConstants.CONSTANT_METHOD: case RuntimeConstants.CONSTANT_INTERFACEMETHOD: case RuntimeConstants.CONSTANT_FIELD: { CPX2 x = (CPX2) (cls.getCpoolEntry(cpx)); if (x.cpx1 == cls.getthis_cpx()) { // don't print class part for local references cpx = x.cpx2; } } } out.print(cls.TagString(tag) + " " + cls.StringValue(cpx)); }
/** Print constant pool entry information. */ public int PrintlnConstantEntry(int cpx) { int size = 1; byte tag = 0; try { tag = cls.getTag(cpx); } catch (IndexOutOfBoundsException e) { out.println(" <Incorrect CP index>"); return 1; } out.print(cls.StringTag(cpx) + "\t"); Object x = cls.getCpoolEntryobj(cpx); if (x == null) { switch (tag) { case RuntimeConstants.CONSTANT_LONG: case RuntimeConstants.CONSTANT_DOUBLE: size = 2; } out.println("null;"); return size; } String str = cls.StringValue(cpx); switch (tag) { case RuntimeConstants.CONSTANT_CLASS: case RuntimeConstants.CONSTANT_STRING: out.println("#" + (((CPX) x).cpx) + ";\t// " + str); break; case RuntimeConstants.CONSTANT_FIELD: case RuntimeConstants.CONSTANT_METHOD: case RuntimeConstants.CONSTANT_INTERFACEMETHOD: out.println("#" + ((CPX2) x).cpx1 + ".#" + ((CPX2) x).cpx2 + ";\t// " + str); break; case RuntimeConstants.CONSTANT_NAMEANDTYPE: out.println("#" + ((CPX2) x).cpx1 + ":#" + ((CPX2) x).cpx2 + ";// " + str); break; case RuntimeConstants.CONSTANT_LONG: case RuntimeConstants.CONSTANT_DOUBLE: size = 2; default: out.println(str + ";"); } return size; }