/** * Returns the type descriptor as a <code>String</code> for this type * @return the type descriptor as a <code>String</code> for this type */ public String getTypeDescriptor() { return typeDescriptor.getStringValue(); }
/** {@inheritDoc} */ public int compareTo(StringIdItem o) { //sort by the string value return getStringValue().compareTo(o.getStringValue()); }
public static boolean looksLikeSyntheticAccessor(MethodIdItem methodIdItem) { return methodIdItem.getMethodName().getStringValue().startsWith("access$"); }
/** * @return a string formatted like methodName(TTTT..)R */ public String getVirtualMethodString() { if (cachedVirtualMethodString == null) { String methodName = this.methodName.getStringValue(); String prototypeString = methodPrototype.getPrototypeString(); StringBuilder sb = new StringBuilder(methodName.length() + prototypeString.length()); sb.append(methodName); sb.append(prototypeString); cachedVirtualMethodString = sb.toString(); } return cachedVirtualMethodString; }
/** {@inheritDoc} */ public String getConciseIdentity() { return "string_id_item: " + Utf8Utils.escapeString(getStringValue()); }
/** * @return a string formatted like LclassName;->fieldName:fieldType */ public String getFieldString() { if (cachedFieldString == null) { String typeDescriptor = classType.getTypeDescriptor(); String fieldName = this.fieldName.getStringValue(); String fieldType = this.fieldType.getTypeDescriptor(); StringBuffer sb = new StringBuffer(typeDescriptor.length() + fieldName.length() + fieldType.length() + 3); sb.append(typeDescriptor); sb.append("->"); sb.append(fieldName); sb.append(":"); sb.append(fieldType); cachedFieldString = sb.toString(); } return cachedFieldString; }
/** * @return a string formatted like LclassName;->methodName(TTTT..)R */ public String getMethodString() { if (cachedMethodString == null) { String classType = this.classType.getTypeDescriptor(); String methodName = this.methodName.getStringValue(); String prototypeString = methodPrototype.getPrototypeString(); StringBuilder sb = new StringBuilder(classType.length() + methodName.length() + prototypeString.length() + 2); sb.append(classType); sb.append("->"); sb.append(methodName); sb.append(prototypeString); cachedMethodString = sb.toString(); } return cachedMethodString; }
protected boolean isInvokeInit() { if (instruction == null || !instruction.opcode.canInitializeReference()) { return false; } //TODO: check access flags instead of name? InstructionWithReference instruction = (InstructionWithReference)this.instruction; Item item = instruction.getReferencedItem(); assert item.getItemType() == ItemType.TYPE_METHOD_ID_ITEM; MethodIdItem method = (MethodIdItem)item; if (!method.getMethodName().getStringValue().equals("<init>")) { return false; } return true; }
private String[][] loadInstanceFields(ClassDataItem classDataItem) { EncodedField[] encodedFields = classDataItem.getInstanceFields(); if (encodedFields != null && encodedFields.length > 0) { String[][] instanceFields = new String[encodedFields.length][2]; for (int i=0; i<encodedFields.length; i++) { EncodedField encodedField = encodedFields[i]; instanceFields[i][0] = encodedField.field.getFieldName().getStringValue(); instanceFields[i][1] = encodedField.field.getFieldType().getTypeDescriptor(); } return instanceFields; } return null; } }
@Override public void ProcessSetFile(int startDebugOffset, int length, int nameIndex) { out.annotate("DBG_SET_FILE"); out.writeByte(DebugOpcode.DBG_SET_FILE.value); if (nameIndex != -1) { Item sourceItem = referencedItems[referencedItemsPosition++]; assert sourceItem instanceof StringIdItem; out.annotate("source_file: \"" + ((StringIdItem)sourceItem).getStringValue() + "\""); out.writeUnsignedLeb128(sourceItem.getIndex() + 1); } else { out.annotate("source_file: "); out.writeByte(0); } }
/** {@inheritDoc} */ protected void writeItem(AnnotatedOutput out) { if (out.annotates()) { out.annotate(2, "class_type: " + classType.getTypeDescriptor()); out.annotate(2, "method_prototype: " + methodPrototype.getPrototypeString()); out.annotate(4, "method_name: " + methodName.getStringValue()); } int classIndex = classType.getIndex(); if (classIndex > 0xffff) { throw new RuntimeException(String.format("Error writing method_id_item for %s. The type index of " + "defining class %s is too large", getMethodString(), classType.getTypeDescriptor())); } out.writeShort(classIndex); int prototypeIndex = methodPrototype.getIndex(); if (prototypeIndex > 0xffff) { throw new RuntimeException(String.format("Error writing method_id_item for %0. The prototype index of " + "method prototype %s is too large", getMethodString(), methodPrototype.getPrototypeString())); } out.writeShort(prototypeIndex); out.writeInt(methodName.getIndex()); }
/** {@inheritDoc} */ protected void writeItem(AnnotatedOutput out) { if (out.annotates()) { out.annotate(2, "class_type: " + classType.getTypeDescriptor()); out.annotate(2, "field_type: " + fieldType.getTypeDescriptor()); out.annotate(4, "field_name: " + fieldName.getStringValue()); } int classIndex = classType.getIndex(); if (classIndex > 0xffff) { throw new RuntimeException(String.format("Error writing field_id_item for %s. The type index of " + "defining class %s is too large", getFieldString(), classType.getTypeDescriptor())); } out.writeShort(classIndex); int typeIndex = fieldType.getIndex(); if (typeIndex > 0xffff) { throw new RuntimeException(String.format("Error writing field_id_item for %s. The type index of field " + "type %s is too large", getFieldString(), fieldType.getTypeDescriptor())); } out.writeShort(typeIndex); out.writeInt(fieldName.getIndex()); }
/** {@inheritDoc} */ public void writeValue(AnnotatedOutput out) { byte[] bytes = EncodedValueUtils.encodeUnsignedIntegralValue(value.getIndex()); if (out.annotates()) { out.annotate(1, "value_type=" + ValueType.VALUE_STRING.name() + ",value_arg=" + (bytes.length - 1)); out.annotate(bytes.length, "value: \"" + Utf8Utils.escapeString(value.getStringValue()) + "\""); } out.writeByte(ValueType.VALUE_STRING.value | ((bytes.length - 1) << 5)); out.write(bytes); }
MethodIdItem methodIdItem = (MethodIdItem)item; if (!methodIdItem.getMethodName().getStringValue().equals("<init>")) { return;
/** {@inheritDoc} */ public void writeValue(AnnotatedOutput out) { out.annotate("annotation_type: " + annotationType.getTypeDescriptor()); out.writeUnsignedLeb128(annotationType.getIndex()); out.annotate("element_count: 0x" + Integer.toHexString(names.length) + " (" + names.length + ")"); out.writeUnsignedLeb128(names.length); for (int i=0; i<names.length; i++) { out.annotate(0, "[" + i + "] annotation_element"); out.indent(); out.annotate("element_name: " + names[i].getStringValue()); out.writeUnsignedLeb128(names[i].getIndex()); out.annotate(0, "element_value:"); out.indent(); values[i].writeValue(out); out.deindent(); out.deindent(); } }
/** {@inheritDoc} */ protected void writeItem(AnnotatedOutput out) { if (out.annotates()) { out.annotate(4, "shorty_descriptor: " + shortyDescriptor.getStringValue()); out.annotate(4, "return_type: " + returnType.getTypeDescriptor()); if (parameters == null) { out.annotate(4, "parameters:"); } else { out.annotate(4, "parameters: " + parameters.getTypeListString("")); } } out.writeInt(shortyDescriptor.getIndex()); out.writeInt(returnType.getIndex()); out.writeInt(parameters == null?0:parameters.getOffset()); }
Item nameItem = referencedItems[referencedItemsPosition++]; assert nameItem instanceof StringIdItem; out.annotate("name: " + ((StringIdItem)nameItem).getStringValue()); out.writeUnsignedLeb128(nameItem.getIndex() + 1); } else { Item signatureItem = referencedItems[referencedItemsPosition++]; assert signatureItem instanceof StringIdItem; out.annotate("signature: " + ((StringIdItem)signatureItem).getStringValue()); out.writeUnsignedLeb128(signatureItem.getIndex() + 1); } else {
/** {@inheritDoc} */ protected void writeItem(AnnotatedOutput out) { if (out.annotates()) { out.annotate(4, "class_type: " + classType.getTypeDescriptor()); out.annotate(4, "access_flags: " + AccessFlags.formatAccessFlagsForClass(accessFlags)); out.annotate(4, "superclass_type: " + (superType==null?"":superType.getTypeDescriptor())); out.annotate(4, "interfaces: " + (implementedInterfaces==null?"":implementedInterfaces.getTypeListString(" "))); out.annotate(4, "source_file: " + (sourceFile==null?"":sourceFile.getStringValue())); out.annotate(4, "annotations_off: " + (annotations==null?"":"0x"+Integer.toHexString(annotations.getOffset()))); out.annotate(4, "class_data_off:" + (classData==null?"":"0x"+Integer.toHexString(classData.getOffset()))); out.annotate(4, "static_values_off: " + (staticFieldInitializers==null?"":"0x"+Integer.toHexString(staticFieldInitializers.getOffset()))); } out.writeInt(classType.getIndex()); out.writeInt(accessFlags); out.writeInt(superType==null?-1:superType.getIndex()); out.writeInt(implementedInterfaces==null?0:implementedInterfaces.getOffset()); out.writeInt(sourceFile==null?-1:sourceFile.getIndex()); out.writeInt(annotations==null?0:annotations.getOffset()); out.writeInt(classData==null?0:classData.getOffset()); out.writeInt(staticFieldInitializers==null?0:staticFieldInitializers.getOffset()); }
Item nameItem = referencedItems[referencedItemsPosition++]; assert nameItem instanceof StringIdItem; out.annotate("name: " + ((StringIdItem)nameItem).getStringValue()); out.writeUnsignedLeb128(nameItem.getIndex() + 1); } else {
out.annotate(4, "field: " + fieldAnnotationFields[i].getFieldName().getStringValue() + ":" + fieldAnnotationFields[i].getFieldType().getTypeDescriptor()); out.annotate(4, "annotations_off: 0x" + Integer.toHexString(fieldAnnotations[i].getOffset()));