Program: 187305
Project: 187305
Buggy source:
private Object invokeAndReturn(Method method,Object[] originalArgs,Object proxy,MethodInfo info){
  final int depth=info.chain().length;
  Object[] newArgs=new Object[originalArgs.length + depth];
  Class<?>[] originalTypes=method.getParameterTypes();
  Class[] newTypes=new Class[originalTypes.length + depth];
  for (int i=0; i < depth; ++i) {
    newArgs[originalArgs.length + i]=new ObjectWrapper();
    newTypes[originalTypes.length + i]=ObjectWrapper.class;
  }
  System.arraycopy(originalArgs,0,newArgs,0,originalArgs.length);
  System.arraycopy(originalTypes,0,newTypes,0,originalTypes.length);
  Method helperMethod;
  try {
    helperMethod=helper.getClass().getMethod(method.getName(),newTypes);
  }
 catch (  NoSuchMethodException ex) {
    throw new IllegalStateException("String_Node_Str",ex);
  }
  if (!helperMethod.isAccessible()) {
    helperMethod.setAccessible(true);
  }
  Object result;
  try {
    result=helperMethod.invoke(helper,newArgs);
  }
 catch (  IllegalAccessException ex) {
    throw new IllegalStateException(ex);
  }
catch (  InvocationTargetException ex) {
    if (ex.getTargetException() instanceof RuntimeException) {
      throw (RuntimeException)ex.getTargetException();
    }
 else {
      throw new RuntimeException(ex.getTargetException());
    }
  }
  Object _returnValue;
switch (info.type()) {
case 3:
    _returnValue=returnValue;
  break;
case 1:
if (depth > 0) {
  LateralHint hint=method.getAnnotation(LateralHint.class);
  if (hint == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  _returnValue=this._proxy(hint.next());
}
 else {
  _returnValue=this._proxy(method.getReturnType());
}
break;
case 0:
_returnValue=proxy;
break;
case 2:
if (helperMethod.getReturnType().equals(void.class)) {
_returnValue=returnValue;
}
 else {
_returnValue=result;
}
break;
default :
throw new IllegalStateException("String_Node_Str");
}
for (int i=depth - 1; i >= 0; --i) {
ObjectWrapper wrapper=(ObjectWrapper)newArgs[originalArgs.length + i];
if (wrapper.get() == null) {
throw new IllegalStateException("String_Node_Str" + method.getName());
}
BlockInvocationHandler handler=new BlockInvocationHandler(wrapper.get(),_returnValue);
_returnValue=handler._proxy(info.chain()[i]);
}
return _returnValue;
}

Fixed version (ground truth):
private Object invokeAndReturn(Method method,Object[] originalArgs,Object proxy,MethodInfo info){
  final int depth=info.chain().length;
  Object[] newArgs=new Object[originalArgs.length + depth];
  Class<?>[] originalTypes=method.getParameterTypes();
  Class[] newTypes=new Class[originalTypes.length + depth];
  for (int i=0; i < depth; ++i) {
    newArgs[originalArgs.length + i]=new ObjectWrapper();
    newTypes[originalTypes.length + i]=ObjectWrapper.class;
  }
  System.arraycopy(originalArgs,0,newArgs,0,originalArgs.length);
  System.arraycopy(originalTypes,0,newTypes,0,originalTypes.length);
  Method helperMethod;
  try {
    helperMethod=helper.getClass().getMethod(method.getName(),newTypes);
  }
 catch (  NoSuchMethodException ex) {
    throw new IllegalStateException("String_Node_Str",ex);
  }
  if (!helperMethod.isAccessible()) {
    helperMethod.setAccessible(true);
  }
  Object result;
  try {
    result=helperMethod.invoke(helper,newArgs);
  }
 catch (  IllegalAccessException ex) {
    throw new IllegalStateException(ex);
  }
catch (  InvocationTargetException ex) {
    if (ex.getTargetException() instanceof RuntimeException) {
      throw (RuntimeException)ex.getTargetException();
    }
 else {
      throw new RuntimeException(ex.getTargetException());
    }
  }
  Object _returnValue=computeReturnValue(method,proxy,info,depth,helperMethod,result);
  for (int i=depth - 1; i >= 0; --i) {
    ObjectWrapper wrapper=(ObjectWrapper)newArgs[originalArgs.length + i];
    if (wrapper.get() == null) {
      throw new IllegalStateException("String_Node_Str" + method.getName());
    }
    BlockInvocationHandler handler=new BlockInvocationHandler(wrapper.get(),_returnValue);
    _returnValue=handler._proxy(info.chain()[i]);
  }
  return _returnValue;
}