/** * {@inheritDoc} */ @Override public SubstitutionDescriptor getSubstitutionDescriptor() { return new SubstitutionDescriptor(true, true); }
/** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + (int) (this.id ^ (this.id >>> 32)); result = (prime * result) + (int) (this.sensorId ^ (this.sensorId >>> 32)); result = (prime * result) + ((this.substitutionDescriptor == null) ? 0 : this.substitutionDescriptor.hashCode()); return result; }
/** * {@inheritDoc} */ @Override protected void onMethodEnter() { // generate code for calling before body generateBeforeBodyCall(); if (substitutionDescriptor.isReturnValueSubstitution()) { // and code for returning if result is not null generateReturnIfResultNotNull(); } else { // pop to clear result on stack pop(); } if (substitutionDescriptor.isParameterValueSubstitution()) { // add code for substituting the parameter generateParameterSubstitutionIfResultNotNull(); } // start our try block visitLabel(tryBlockStart); }
/** * {@inheritDoc} */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } SpecialInstrumentationPoint other = (SpecialInstrumentationPoint) obj; if (this.id != other.id) { return false; } if (this.sensorId != other.sensorId) { return false; } if (this.substitutionDescriptor == null) { if (other.substitutionDescriptor != null) { return false; } } else if (!this.substitutionDescriptor.equals(other.substitutionDescriptor)) { return false; } return true; }
if (substitutionDescriptor.isReturnValueSubstitution()) {
/** * Generates before body call. */ private void generateBeforeBodyCall() { // load hook dispatcher loadHookDispatcher(); // first push method id push(methodId); // then this object or null if's static if (isStatic) { pushNull(); } else { loadThis(); } // then parameters loadArgArray(); if (substitutionDescriptor.isParameterValueSubstitution()) { // note here that we are saving the passed array as local variable // this enables us to substitute the parameters later on if they are changed in the // beforeBody passedArgumentsLocal = newLocal(IInstrumenterConstant.OBJECT_ARRAY_TYPE); storeLocal(passedArgumentsLocal); loadLocal(passedArgumentsLocal); } mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, IInstrumenterConstant.IHOOK_DISPATCHER_INTERNAL_NAME, "dispatchSpecialMethodBeforeBody", IInstrumenterConstant.DISPATCH_SPECIAL_METHOD_BEFORE_BODY_DESCRIPTOR, true); }
/** * {@inheritDoc} */ @Override public SubstitutionDescriptor getSubstitutionDescriptor() { return new SubstitutionDescriptor(false, true); } }
/** * {@inheritDoc} */ @Override public SubstitutionDescriptor getSubstitutionDescriptor() { return new SubstitutionDescriptor(true, false); }
/** * {@inheritDoc} */ @Override public SubstitutionDescriptor getSubstitutionDescriptor() { return new SubstitutionDescriptor(false, true); } }
/** * {@inheritDoc} */ @Override public SubstitutionDescriptor getSubstitutionDescriptor() { // we just use for intercepting, no substitutions return new SubstitutionDescriptor(false, false); }
@BeforeMethod public void setReturnValueDescriptor() { when(sip.getSubstitutionDescriptor()).thenReturn(new SubstitutionDescriptor(true, true)); }
@BeforeMethod public void setReturnValueDescriptor() { when(sip.getSubstitutionDescriptor()).thenReturn(new SubstitutionDescriptor(false, false)); }
@BeforeMethod public void setReturnValueDescriptor() { when(sip.getSubstitutionDescriptor()).thenReturn(new SubstitutionDescriptor(false, true)); }
@BeforeMethod public void setReturnValueDescriptor() { when(sip.getSubstitutionDescriptor()).thenReturn(new SubstitutionDescriptor(true, false)); }