/** {@inheritDoc} */ public String getConciseIdentity() { return "method_id_item: " + getMethodString(); }
/** {@inheritDoc} */ public String getConciseIdentity() { if (this.parent == null) { return "code_item @0x" + Integer.toHexString(getOffset()); } return "code_item @0x" + Integer.toHexString(getOffset()) + " (" + parent.method.getMethodString() + ")"; }
/** * Iterates over the method annotations, calling delegate.processMethodAnnotations for each * @param delegate the delegate to call */ public void iterateMethodAnnotations(MethodAnnotationIteratorDelegate delegate) { for (int i=0; i<methodAnnotationMethods.length; i++) { try { delegate.processMethodAnnotations(methodAnnotationMethods[i], methodAnnotations[i]); } catch (Exception ex) { throw addExceptionContext(ExceptionWithContext.withContext(ex, "Error occured while processing method annotations for method: " + methodAnnotationMethods[i].getMethodString())); } } }
/** * Iterates over the parameter annotations, calling delegate.processParameterAnnotations for each * @param delegate the delegate to call */ public void iterateParameterAnnotations(ParameterAnnotationIteratorDelegate delegate) { for (int i=0; i<parameterAnnotationMethods.length; i++) { try { delegate.processParameterAnnotations(parameterAnnotationMethods[i], parameterAnnotations[i]); } catch (Exception ex) { throw addExceptionContext(ExceptionWithContext.withContext(ex, "Error occured while processing parameter annotations for method: " + parameterAnnotationMethods[i].getMethodString())); } } }
ex.addContext(String.format("opcode: %s", instructionToVerify.instruction.opcode.name)); ex.addContext(String.format("CodeAddress: %d", codeAddress)); ex.addContext(String.format("Method: %s", encodedMethod.method.getMethodString())); break;
/** {@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} */ public void writeValue(AnnotatedOutput out) { byte[] bytes = EncodedValueUtils.encodeUnsignedIntegralValue(value.getIndex()); if (out.annotates()) { out.annotate(1, "value_type=" + ValueType.VALUE_METHOD.name() + ",value_arg=" + (bytes.length - 1)); out.annotate(bytes.length, "value: " + value.getMethodString()); } out.writeByte(ValueType.VALUE_METHOD.value | ((bytes.length - 1) << 5)); out.write(bytes); }
} else { throw new ValidationException(String.format("Cannot call constructor %s with %s", methodIdItem.getMethodString(), analyzedInstruction.instruction.opcode.name)); if (!methodClassDef.isInterface()) { throw new ValidationException(String.format("Cannot call method %s with %s. %s is not an interface " + "class.", methodIdItem.getMethodString(), analyzedInstruction.instruction.opcode.name, methodClassDef.getClassType())); if (methodClassDef.isInterface()) { throw new ValidationException(String.format("Cannot call method %s with %s. %s is an interface class." + " Use invoke-interface or invoke-interface/range instead.", methodIdItem.getMethodString(), analyzedInstruction.instruction.opcode.name, methodClassDef.getClassType())); if (currentMethodClassDef.getSuperclass() == null) { throw new ValidationException(String.format("Cannot call method %s with %s. %s has no superclass", methodIdItem.getMethodString(), analyzedInstruction.instruction.opcode.name, methodClassDef.getSuperclass().getClassType())); "of the current class %s", methodIdItem.getMethodString(), analyzedInstruction.instruction.opcode.name, methodClass.getTypeDescriptor(), encodedMethod.method.getContainingClass().getTypeDescriptor())); "no such method", methodIdItem.getMethodString(), analyzedInstruction.instruction.opcode.name, methodClassDef.getSuperclass().getClassType())); "parameters for method %s. Expecting %d registers, got %d.", methodIdItem.getMethodString(), methodParameterRegisterCount + 1, registers.getCount()));
ex.addContext(String.format("opcode: %s", instructionToAnalyze.instruction.opcode.name)); ex.addContext(String.format("CodeAddress: %d", codeAddress)); ex.addContext(String.format("Method: %s", encodedMethod.method.getMethodString())); break;
out.annotate(0, parent.method.getMethodString()); out.annotate(2, "registers_size: 0x" + Integer.toHexString(registerCount) + " (" + registerCount + ")"); out.annotate(2, "ins_size: 0x" + Integer.toHexString(inWords) + " (" + inWords + ")");
out.annotate(0, parent.getParent().method.getMethodString()); out.annotate("line_start: 0x" + Integer.toHexString(lineStart) + " (" + lineStart + ")"); out.writeUnsignedLeb128(lineStart);
/** * Writes the <code>EncodedMethod</code> to the given <code>AnnotatedOutput</code> object * @param out the <code>AnnotatedOutput</code> object to write to * @param previousEncodedMethod The previous <code>EncodedMethod</code> in the list containing this * <code>EncodedMethod</code>. */ private void writeTo(AnnotatedOutput out, EncodedMethod previousEncodedMethod) { int previousIndex = previousEncodedMethod==null?0:previousEncodedMethod.method.getIndex(); if (out.annotates()) { out.annotate("method: " + method.getMethodString()); out.writeUnsignedLeb128(method.getIndex() - previousIndex); out.annotate("access_flags: " + AccessFlags.formatAccessFlagsForMethod(accessFlags)); out.writeUnsignedLeb128(accessFlags); if (codeItem != null) { out.annotate("code_off: 0x" + Integer.toHexString(codeItem.getOffset())); out.writeUnsignedLeb128(codeItem.getOffset()); } else { out.annotate("code_off: 0x0"); out.writeUnsignedLeb128(0); } }else { out.writeUnsignedLeb128(method.getIndex() - previousIndex); out.writeUnsignedLeb128(accessFlags); out.writeUnsignedLeb128(codeItem==null?0:codeItem.getOffset()); } }
out.annotate(0, "[" + index++ + "] method_annotation"); out.indent(); out.annotate(4, "method: " + methodAnnotationMethods[i].getMethodString()); out.annotate(4, "annotations_off: 0x" + Integer.toHexString(methodAnnotations[i].getOffset())); out.deindent(); out.annotate(0, "[" + index++ + "] parameter_annotation"); out.indent(); out.annotate(4, "method: " + parameterAnnotationMethods[i].getMethodString()); out.annotate(4, "annotations_off: 0x" + Integer.toHexString(parameterAnnotations[i].getOffset()));
/** {@inheritDoc} */ public String getConciseIdentity() { return "method_id_item: " + getMethodString(); }
/** {@inheritDoc} */ public String getConciseIdentity() { if (this.parent == null) { return "code_item @0x" + Integer.toHexString(getOffset()); } return "code_item @0x" + Integer.toHexString(getOffset()) + " (" + parent.method.getMethodString() + ")"; }
ex.addContext(String.format("opcode: %s", instructionToVerify.instruction.opcode.name)); ex.addContext(String.format("CodeAddress: %d", codeAddress)); ex.addContext(String.format("Method: %s", encodedMethod.method.getMethodString())); break;
/** * Writes the <code>EncodedMethod</code> to the given <code>AnnotatedOutput</code> object * @param out the <code>AnnotatedOutput</code> object to write to * @param previousEncodedMethod The previous <code>EncodedMethod</code> in the list containing this * <code>EncodedMethod</code>. */ private void writeTo(AnnotatedOutput out, EncodedMethod previousEncodedMethod) { int previousIndex = previousEncodedMethod==null?0:previousEncodedMethod.method.getIndex(); if (out.annotates()) { out.annotate("method: " + method.getMethodString()); out.writeUnsignedLeb128(method.getIndex() - previousIndex); out.annotate("access_flags: " + AccessFlags.formatAccessFlagsForMethod(accessFlags)); out.writeUnsignedLeb128(accessFlags); if (codeItem != null) { out.annotate("code_off: 0x" + Integer.toHexString(codeItem.getOffset())); out.writeUnsignedLeb128(codeItem.getOffset()); } else { out.annotate("code_off: 0x0"); out.writeUnsignedLeb128(0); } }else { out.writeUnsignedLeb128(method.getIndex() - previousIndex); out.writeUnsignedLeb128(accessFlags); out.writeUnsignedLeb128(codeItem==null?0:codeItem.getOffset()); } }
/** {@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} */ public void writeValue(AnnotatedOutput out) { byte[] bytes = EncodedValueUtils.encodeUnsignedIntegralValue(value.getIndex()); if (out.annotates()) { out.annotate(1, "value_type=" + ValueType.VALUE_METHOD.name() + ",value_arg=" + (bytes.length - 1)); out.annotate(bytes.length, "value: " + value.getMethodString()); } out.writeByte(ValueType.VALUE_METHOD.value | ((bytes.length - 1) << 5)); out.write(bytes); }
out.annotate(0, parent.method.getMethodString()); out.annotate(2, "registers_size: 0x" + Integer.toHexString(registerCount) + " (" + registerCount + ")"); out.annotate(2, "ins_size: 0x" + Integer.toHexString(inWords) + " (" + inWords + ")");