/** * Read constant pool entries. * @throws IOException * @throws ClassFormatException */ private final void readConstantPool() throws IOException, ClassFormatException { constant_pool = new ConstantPool(file); }
/** * @return the annotation type name */ public String getAnnotationType() { final ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(type_index, CONSTANT_Utf8); return c.getBytes(); }
/** * Retrieve constant at `index' from constant pool and resolve it to * a string representation. * * @param index of constant in constant pool * @param tag expected type * @return String representation */ public String constantToString( int index, byte tag ) throws ClassFormatException { Constant c = getConstant(index, tag); return constantToString(c); }
case Constants.CONSTANT_Class: i = ((ConstantClass) c).getNameIndex(); c = getConstant(i, Constants.CONSTANT_Utf8); str = Utility.compactClassName(((ConstantUtf8) c).getBytes()); break; case Constants.CONSTANT_String: i = ((ConstantString) c).getStringIndex(); c = getConstant(i, Constants.CONSTANT_Utf8); str = "\"" + escape(((ConstantUtf8) c).getBytes()) + "\""; break; case Constants.CONSTANT_Utf8: break; case Constants.CONSTANT_NameAndType: str = (constantToString(((ConstantNameAndType) c).getNameIndex(), Constants.CONSTANT_Utf8) + " " + constantToString(((ConstantNameAndType) c).getSignatureIndex(), Constants.CONSTANT_Utf8)); break; case Constants.CONSTANT_Methodref: case Constants.CONSTANT_Fieldref: str = (constantToString(((ConstantCP) c).getClassIndex(), Constants.CONSTANT_Class) + "." + constantToString(((ConstantCP) c).getNameAndTypeIndex(), Constants.CONSTANT_NameAndType)); break;
index = bytes.readUnsignedShort(); buf.append("\t\t").append( constant_pool.constantToString(index, Constants.CONSTANT_Fieldref)).append( (verbose ? " (" + index + ")" : "")); break; index = bytes.readUnsignedShort(); buf.append("\t<").append( constant_pool.constantToString(index, Constants.CONSTANT_Class)) .append(">").append((verbose ? " (" + index + ")" : "")); break; index = bytes.readUnsignedShort(); buf.append("\t").append( constant_pool.constantToString(index, Constants.CONSTANT_Methodref)) .append((verbose ? " (" + index + ")" : "")); break; buf.append("\t").append( constant_pool .constantToString(index, Constants.CONSTANT_InterfaceMethodref)) .append(verbose ? " (" + index + ")\t" : "").append(nargs).append("\t") index = bytes.readUnsignedShort(); buf.append("\t\t").append( constant_pool.constantToString(index, constant_pool.getConstant(index) .getTag())).append((verbose ? " (" + index + ")" : "")); break;
/** * @return Resolved string representation */ public final String toString( ConstantPool constant_pool ) { String inner_class_name, outer_class_name, inner_name, access; inner_class_name = constant_pool.getConstantString(inner_class_index, Constants.CONSTANT_Class); inner_class_name = Utility.compactClassName(inner_class_name); if (outer_class_index != 0) { outer_class_name = constant_pool.getConstantString(outer_class_index, Constants.CONSTANT_Class); outer_class_name = Utility.compactClassName(outer_class_name); } else { outer_class_name = "<not a member>"; } if (inner_name_index != 0) { inner_name = ((ConstantUtf8) constant_pool.getConstant(inner_name_index, Constants.CONSTANT_Utf8)).getBytes(); } else { inner_name = "<anonymous>"; } access = Utility.accessToString(inner_access_flags, true); access = access.equals("") ? "" : (access + " "); return "InnerClass:" + access + inner_class_name + "(\"" + outer_class_name + "\", \"" + inner_name + "\")"; }
/** * @return String representation. */ public final String toString( ConstantPool cp, boolean verbose ) { String str; if (catch_type == 0) { str = "<Any exception>(0)"; } else { str = Utility.compactClassName(cp.getConstantString(catch_type, CONSTANT_Class), false) + (verbose ? "(" + catch_type + ")" : ""); } return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str; }
private String printIndex() { if (type == Constants.ITEM_Object) { if (index < 0) { return ", class=<unknown>"; } return ", class=" + constant_pool.constantToString(index, Constants.CONSTANT_Class); } else if (type == Constants.ITEM_NewObject) { return ", offset=" + index; } else { return ""; } }
buf.append("compiler version\t").append(major).append(".").append(minor).append('\n'); buf.append("access flags\t\t").append(access_flags).append('\n'); buf.append("constant pool\t\t").append(constant_pool.getLength()).append(" entries\n"); buf.append("ACC_SUPER flag\t\t").append(isSuper()).append("\n"); if (attributes.length > 0) {
case Constants.CONSTANT_Class: i = ((ConstantClass) c).getNameIndex(); c = getConstant(i, Constants.CONSTANT_Utf8); str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false); break; case Constants.CONSTANT_String: i = ((ConstantString) c).getStringIndex(); c = getConstant(i, Constants.CONSTANT_Utf8); str = "\"" + escape(((ConstantUtf8) c).getBytes()) + "\""; break; case Constants.CONSTANT_Utf8: break; case Constants.CONSTANT_NameAndType: str = (constantToString(((ConstantNameAndType) c).getNameIndex(), Constants.CONSTANT_Utf8) + " " + constantToString(((ConstantNameAndType) c).getSignatureIndex(), Constants.CONSTANT_Utf8)); break; case Constants.CONSTANT_Methodref: case Constants.CONSTANT_Fieldref: str = (constantToString(((ConstantCP) c).getClassIndex(), Constants.CONSTANT_Class) + "." + constantToString(((ConstantCP) c).getNameAndTypeIndex(), Constants.CONSTANT_NameAndType)); break;
index = bytes.readUnsignedShort(); buf.append("\t\t").append( constant_pool.constantToString(index, Constants.CONSTANT_Fieldref)).append( (verbose ? " (" + index + ")" : "")); break; index = bytes.readUnsignedShort(); buf.append("\t<").append( constant_pool.constantToString(index, Constants.CONSTANT_Class)) .append(">").append((verbose ? " (" + index + ")" : "")); break; index = bytes.readUnsignedShort(); buf.append("\t").append( constant_pool.constantToString(index, Constants.CONSTANT_Methodref)) .append((verbose ? " (" + index + ")" : "")); break; buf.append("\t").append( constant_pool .constantToString(index, Constants.CONSTANT_InterfaceMethodref)) .append(verbose ? " (" + index + ")\t" : "").append(nargs).append("\t") index = bytes.readUnsignedShort(); buf.append("\t\t").append( constant_pool.constantToString(index, constant_pool.getConstant(index) .getTag())).append((verbose ? " (" + index + ")" : "")); break;
/** * @return Resolved string representation */ public final String toString( ConstantPool constant_pool ) { String inner_class_name, outer_class_name, inner_name, access; inner_class_name = constant_pool.getConstantString(inner_class_index, Constants.CONSTANT_Class); inner_class_name = Utility.compactClassName(inner_class_name); if (outer_class_index != 0) { outer_class_name = constant_pool.getConstantString(outer_class_index, Constants.CONSTANT_Class); outer_class_name = Utility.compactClassName(outer_class_name); } else { outer_class_name = "<not a member>"; } if (inner_name_index != 0) { inner_name = ((ConstantUtf8) constant_pool.getConstant(inner_name_index, Constants.CONSTANT_Utf8)).getBytes(); } else { inner_name = "<anonymous>"; } access = Utility.accessToString(inner_access_flags, true); access = access.equals("") ? "" : (access + " "); return "InnerClass:" + access + inner_class_name + "(\"" + outer_class_name + "\", \"" + inner_name + "\")"; }
/** * @return String representation. */ public final String toString( ConstantPool cp, boolean verbose ) { String str; if (catch_type == 0) { str = "<Any exception>(0)"; } else { str = Utility.compactClassName(cp.getConstantString(catch_type, CONSTANT_Class), false) + (verbose ? "(" + catch_type + ")" : ""); } return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str; }
private String printIndex() { if (type == Constants.ITEM_Object) { if (index < 0) { return ", class=<unknown>"; } return ", class=" + constant_pool.constantToString(index, Constants.CONSTANT_Class); } else if (type == Constants.ITEM_NewObject) { return ", offset=" + index; } else { return ""; } }
buf.append("compiler version\t").append(major).append(".").append(minor).append('\n'); buf.append("access flags\t\t").append(access_flags).append('\n'); buf.append("constant pool\t\t").append(constant_pool.getLength()).append(" entries\n"); buf.append("ACC_SUPER flag\t\t").append(isSuper()).append("\n"); if (attributes.length > 0) {
/** * @return PMG name. */ public final String getPMGName() { ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(pmg_index, Constants.CONSTANT_Utf8); return c.getBytes(); }
case Constants.CONSTANT_Class: i = ((ConstantClass) c).getNameIndex(); c = getConstant(i, Constants.CONSTANT_Utf8); str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false); break; case Constants.CONSTANT_String: i = ((ConstantString) c).getStringIndex(); c = getConstant(i, Constants.CONSTANT_Utf8); str = "\"" + escape(((ConstantUtf8) c).getBytes()) + "\""; break; case Constants.CONSTANT_Utf8: break; case Constants.CONSTANT_NameAndType: str = (constantToString(((ConstantNameAndType) c).getNameIndex(), Constants.CONSTANT_Utf8) + " " + constantToString(((ConstantNameAndType) c).getSignatureIndex(), Constants.CONSTANT_Utf8)); break; case Constants.CONSTANT_Methodref: case Constants.CONSTANT_Fieldref: str = (constantToString(((ConstantCP) c).getClassIndex(), Constants.CONSTANT_Class) + "." + constantToString(((ConstantCP) c).getNameAndTypeIndex(), Constants.CONSTANT_NameAndType)); break;
index = bytes.readUnsignedShort(); buf.append("\t\t").append( constant_pool.constantToString(index, Constants.CONSTANT_Fieldref)).append( (verbose ? " (" + index + ")" : "")); break; index = bytes.readUnsignedShort(); buf.append("\t<").append( constant_pool.constantToString(index, Constants.CONSTANT_Class)) .append(">").append((verbose ? " (" + index + ")" : "")); break; index = bytes.readUnsignedShort(); buf.append("\t").append( constant_pool.constantToString(index, Constants.CONSTANT_Methodref)) .append((verbose ? " (" + index + ")" : "")); break; buf.append("\t").append( constant_pool .constantToString(index, Constants.CONSTANT_InterfaceMethodref)) .append(verbose ? " (" + index + ")\t" : "").append(nargs).append("\t") index = bytes.readUnsignedShort(); buf.append("\t\t").append( constant_pool.constantToString(index, constant_pool.getConstant(index) .getTag())).append((verbose ? " (" + index + ")" : "")); break;
/** * Retrieve constant at `index' from constant pool and resolve it to * a string representation. * * @param index of constant in constant pool * @param tag expected type * @return String representation */ public String constantToString( int index, byte tag ) throws ClassFormatException { Constant c = getConstant(index, tag); return constantToString(c); }
/** * @return Resolved string representation */ public final String toString( ConstantPool constant_pool ) { String inner_class_name, outer_class_name, inner_name, access; inner_class_name = constant_pool.getConstantString(inner_class_index, Constants.CONSTANT_Class); inner_class_name = Utility.compactClassName(inner_class_name); if (outer_class_index != 0) { outer_class_name = constant_pool.getConstantString(outer_class_index, Constants.CONSTANT_Class); outer_class_name = Utility.compactClassName(outer_class_name); } else { outer_class_name = "<not a member>"; } if (inner_name_index != 0) { inner_name = ((ConstantUtf8) constant_pool.getConstant(inner_name_index, Constants.CONSTANT_Utf8)).getBytes(); } else { inner_name = "<anonymous>"; } access = Utility.accessToString(inner_access_flags, true); access = access.equals("") ? "" : (access + " "); return "InnerClass:" + access + inner_class_name + "(\"" + outer_class_name + "\", \"" + inner_name + "\")"; }