nus-yam/ex-repair huggingface dataset:
Program: 164666
Project: 164666
Buggy source:
@Override public void beforeInvocation(@Nonnull IInvokedMethod invokedMethod,@Nonnull ITestResult testResult){
  ITestNGMethod testNGMethod=testResult.getMethod();
  Class<?> testClass=testResult.getTestClass().getRealClass();
  TestRun.clearNoMockingZone();
  if (!invokedMethod.isTestMethod()) {
    beforeConfigurationMethod(testNGMethod,testClass);
    return;
  }
  Method method=testNGMethod.getConstructorOrMethod().getMethod();
  if (Metrics.DataCoverage.active) {
    TestCoverage.INSTANCE.setCurrentTestMethod(method);
  }
  Object testInstance=testResult.getInstance();
  if (testInstance == null || testInstance.getClass() != testClass && !testClass.getClass().getName().equals(testClass.getName())) {
    return;
  }
  TestRun.enterNoMockingZone();
  try {
    TestRun.clearCurrentTestInstance();
    updateTestClassState(testInstance,testClass);
    TestRun.setRunningIndividualTest(testInstance);
    SavePoint testMethodSavePoint=new SavePoint();
    savePoint.set(testMethodSavePoint);
    if (shouldPrepareForNextTest) {
      TestRun.prepareForNextTest();
      shouldPrepareForNextTest=false;
    }
    if (!isMethodWithParametersProvidedByTestNG(method)) {
      Object[] parameters=testResult.getParameters();
      Object[] mockParameters=createInstancesForAnnotatedParameters(testInstance,method,parameters);
      if (mockParameters != null) {
        System.arraycopy(mockParameters,0,parameters,0,parameters.length);
      }
    }
    createInstancesForTestedFields(testInstance,false);
  }
  finally {
    TestRun.exitNoMockingZone();
  }
}

Fixed version (ground truth):
@Override public void beforeInvocation(@Nonnull IInvokedMethod invokedMethod,@Nonnull ITestResult testResult){
  ITestNGMethod testNGMethod=testResult.getMethod();
  Class<?> testClass=testResult.getTestClass().getRealClass();
  TestRun.clearNoMockingZone();
  if (!invokedMethod.isTestMethod()) {
    beforeConfigurationMethod(testNGMethod,testClass);
    return;
  }
  Method method=testNGMethod.getConstructorOrMethod().getMethod();
  if (Metrics.DataCoverage.active) {
    TestCoverage.INSTANCE.setCurrentTestMethod(method);
  }
  Object testInstance=testResult.getInstance();
  if (testInstance == null || testInstance.getClass() != testClass) {
    return;
  }
  TestRun.enterNoMockingZone();
  try {
    TestRun.clearCurrentTestInstance();
    updateTestClassState(testInstance,testClass);
    TestRun.setRunningIndividualTest(testInstance);
    SavePoint testMethodSavePoint=new SavePoint();
    savePoint.set(testMethodSavePoint);
    if (shouldPrepareForNextTest) {
      TestRun.prepareForNextTest();
      shouldPrepareForNextTest=false;
    }
    if (!isMethodWithParametersProvidedByTestNG(method)) {
      Object[] parameters=testResult.getParameters();
      Object[] mockParameters=createInstancesForAnnotatedParameters(testInstance,method,parameters);
      if (mockParameters != null) {
        System.arraycopy(mockParameters,0,parameters,0,parameters.length);
      }
    }
    createInstancesForTestedFields(testInstance,false);
  }
  finally {
    TestRun.exitNoMockingZone();
  }
}
Program: 164667
Project: 164667
Buggy source:
private void generateDynamicCallToMock(){
  Label startOfRealImplementation=null;
  if (!isStatic(methodAccess) && !isConstructor && isMockedSuperclass()) {
    startOfRealImplementation=new Label();
    mw.visitVarInsn(ALOAD,0);
    mw.visitTypeInsn(INSTANCEOF,Type.getInternalName(mockMethods.getRealClass()));
    mw.visitJumpInsn(IFEQ,startOfRealImplementation);
  }
  generateCallToUpdateMockState();
  if (isConstructor) {
    generateConditionalCallForMockedConstructor();
  }
 else {
    generateConditionalCallForMockedMethod(startOfRealImplementation);
  }
}

Fixed version (ground truth):
private void generateDynamicCallToMock(){
  Label startOfRealImplementation=null;
  if (!isStatic(methodAccess) && !isConstructor && isMockedSuperclass()) {
    Class<?> targetClass=mockMethods.getRealClass();
    if (mockedClass.getClassLoader() == targetClass.getClassLoader()) {
      startOfRealImplementation=new Label();
      mw.visitVarInsn(ALOAD,0);
      mw.visitTypeInsn(INSTANCEOF,Type.getInternalName(targetClass));
      mw.visitJumpInsn(IFEQ,startOfRealImplementation);
    }
  }
  generateCallToUpdateMockState();
  if (isConstructor) {
    generateConditionalCallForMockedConstructor();
  }
 else {
    generateConditionalCallForMockedMethod(startOfRealImplementation);
  }
}
Program: 164668
Project: 164668
Buggy source:
@Nullable @Override Object getExistingTestedInstanceIfApplicable(@Nonnull Object testClassInstance){
  Object testedObject=null;
  if (!createAutomatically) {
    testedObject=getFieldValue(testedField,testClassInstance);
    createAutomatically=testedObject == null && !isFinal(testedField.getModifiers());
  }
  return testedObject;
}

Fixed version (ground truth):
@Nullable @Override Object getExistingTestedInstanceIfApplicable(@Nonnull Object testClassInstance){
  Object testedObject=null;
  if (!createAutomatically) {
    Class<?> targetClass=testedField.getType();
    testedObject=getFieldValue(testedField,testClassInstance);
    if (testedObject == null || isNonInstantiableType(targetClass,testedObject)) {
      String providedValue=metadata.value();
      if (!providedValue.isEmpty()) {
        testedObject=Utilities.convertFromString(targetClass,providedValue);
      }
      createAutomatically=testedObject == null && !isFinal(testedField.getModifiers());
    }
  }
  return testedObject;
}
Program: 164669
Project: 164669
Buggy source:
private static boolean isNonInstantiableType(@Nonnull Class<?> targetClass,@Nullable Object currentValue){
  return targetClass.isPrimitive() && defaultValueForPrimitiveType(targetClass).equals(currentValue) || currentValue == null && (targetClass.isArray() || targetClass.isEnum() || targetClass.isAnnotation()|| isWrapperOfPrimitiveType(targetClass));
}

Fixed version (ground truth):
static boolean isNonInstantiableType(@Nonnull Class<?> targetClass,@Nullable Object currentValue){
  return targetClass.isPrimitive() && defaultValueForPrimitiveType(targetClass).equals(currentValue) || currentValue == null && (targetClass.isArray() || targetClass.isEnum() || targetClass.isAnnotation()|| isWrapperOfPrimitiveType(targetClass));
}
Program: 164670
Project: 164670
Buggy source:
@Override public void beforeInvocation(@Nonnull IInvokedMethod invokedMethod,@Nonnull ITestResult testResult){
  ITestNGMethod testNGMethod=testResult.getMethod();
  Class<?> testClass=testResult.getTestClass().getRealClass();
  TestRun.clearNoMockingZone();
  if (!invokedMethod.isTestMethod()) {
    beforeConfigurationMethod(testNGMethod,testClass);
    return;
  }
  Method method=testNGMethod.getConstructorOrMethod().getMethod();
  if (Metrics.DataCoverage.active) {
    TestCoverage.INSTANCE.setCurrentTestMethod(method);
  }
  Object testInstance=testResult.getInstance();
  if (testInstance == null || testInstance.getClass() != testClass && !testClass.getClass().getName().equals(testClass.getName())) {
    return;
  }
  TestRun.enterNoMockingZone();
  try {
    updateTestClassState(testInstance,testClass);
    TestRun.setRunningIndividualTest(testInstance);
    SavePoint testMethodSavePoint=new SavePoint();
    savePoint.set(testMethodSavePoint);
    if (shouldPrepareForNextTest) {
      TestRun.prepareForNextTest();
      shouldPrepareForNextTest=false;
    }
    if (!isMethodWithParametersProvidedByTestNG(method)) {
      Object[] parameters=testResult.getParameters();
      Object[] mockParameters=createInstancesForAnnotatedParameters(testInstance,method,parameters);
      if (mockParameters != null) {
        System.arraycopy(mockParameters,0,parameters,0,parameters.length);
      }
    }
    createInstancesForTestedFields(testInstance,false);
  }
  finally {
    TestRun.exitNoMockingZone();
  }
}

Fixed version (ground truth):
@Override public void beforeInvocation(@Nonnull IInvokedMethod invokedMethod,@Nonnull ITestResult testResult){
  ITestNGMethod testNGMethod=testResult.getMethod();
  Class<?> testClass=testResult.getTestClass().getRealClass();
  TestRun.clearNoMockingZone();
  if (!invokedMethod.isTestMethod()) {
    beforeConfigurationMethod(testNGMethod,testClass);
    return;
  }
  Method method=testNGMethod.getConstructorOrMethod().getMethod();
  if (Metrics.DataCoverage.active) {
    TestCoverage.INSTANCE.setCurrentTestMethod(method);
  }
  Object testInstance=testResult.getInstance();
  if (testInstance == null || testInstance.getClass() != testClass && !testClass.getClass().getName().equals(testClass.getName())) {
    return;
  }
  TestRun.enterNoMockingZone();
  try {
    TestRun.clearCurrentTestInstance();
    updateTestClassState(testInstance,testClass);
    TestRun.setRunningIndividualTest(testInstance);
    SavePoint testMethodSavePoint=new SavePoint();
    savePoint.set(testMethodSavePoint);
    if (shouldPrepareForNextTest) {
      TestRun.prepareForNextTest();
      shouldPrepareForNextTest=false;
    }
    if (!isMethodWithParametersProvidedByTestNG(method)) {
      Object[] parameters=testResult.getParameters();
      Object[] mockParameters=createInstancesForAnnotatedParameters(testInstance,method,parameters);
      if (mockParameters != null) {
        System.arraycopy(mockParameters,0,parameters,0,parameters.length);
      }
    }
    createInstancesForTestedFields(testInstance,false);
  }
  finally {
    TestRun.exitNoMockingZone();
  }
}
Program: 164671
Project: 164671
Buggy source:
boolean doSomething();

Fixed version (ground truth):
Collaborator doSomething();
Program: 164672
Project: 164672
Buggy source:
@Nullable public Object getDefaultValueForReturnType(){
  if (defaultReturnValue == UNDEFINED_DEFAULT_RETURN) {
    Class<?> resolvedReturnType=getReturnTypeAsResolvedFromClassArgument();
    if (resolvedReturnType != null) {
      defaultReturnValue=DefaultValues.computeForType(resolvedReturnType);
      if (defaultReturnValue == null) {
        String returnTypeDesc='L' + resolvedReturnType.getName().replace('.','/') + ';';
        String mockedTypeDesc=getClassDesc();
        defaultReturnValue=MockedTypeCascade.getMock(mockedTypeDesc,arguments.methodNameAndDesc,instance,returnTypeDesc,resolvedReturnType);
      }
      return defaultReturnValue;
    }
    String returnTypeDesc=DefaultValues.getReturnTypeDesc(arguments.methodNameAndDesc);
    defaultReturnValue=DefaultValues.computeForType(returnTypeDesc);
    if (defaultReturnValue == null) {
      String mockedTypeDesc=getClassDesc();
      defaultReturnValue=MockedTypeCascade.getMock(mockedTypeDesc,arguments.methodNameAndDesc,instance,returnTypeDesc,arguments.genericSignature);
    }
  }
  return defaultReturnValue;
}

Fixed version (ground truth):
@Nullable public Object getDefaultValueForReturnType(){
  if (defaultReturnValue == UNDEFINED_DEFAULT_RETURN) {
    Class<?> resolvedReturnType=getReturnTypeAsResolvedFromClassArgument();
    if (resolvedReturnType != null) {
      defaultReturnValue=DefaultValues.computeForType(resolvedReturnType);
      if (defaultReturnValue == null) {
        String returnTypeDesc='L' + resolvedReturnType.getName().replace('.','/') + ';';
        String mockedTypeDesc=getClassDesc();
        defaultReturnValue=MockedTypeCascade.getMock(mockedTypeDesc,arguments.methodNameAndDesc,instance,returnTypeDesc,resolvedReturnType);
      }
      return defaultReturnValue;
    }
    String returnTypeDesc=DefaultValues.getReturnTypeDesc(arguments.methodNameAndDesc);
    if ("String_Node_Str".equals(returnTypeDesc)) {
      return null;
    }
    defaultReturnValue=DefaultValues.computeForType(returnTypeDesc);
    if (defaultReturnValue == null) {
      String mockedTypeDesc=getClassDesc();
      defaultReturnValue=MockedTypeCascade.getMock(mockedTypeDesc,arguments.methodNameAndDesc,instance,returnTypeDesc,arguments.genericSignature);
    }
  }
  return defaultReturnValue;
}
Program: 164673
Project: 164673
Buggy source:
protected static void registerMock(@Nonnull MockedType mockedType,@Nonnull Object mock){
  TestRun.getExecutingTest().registerMock(mockedType.injectable,mock);
}

Fixed version (ground truth):
protected static void registerMock(@Nonnull MockedType mockedType,@Nonnull Object mock){
  TestRun.getExecutingTest().registerMock(mockedType,mock);
}
Program: 164674
Project: 164674
Buggy source:
void add(@Nonnull String mockedTypeDesc,boolean fromMockField,@Nonnull java.lang.reflect.Type mockedType){
  if (!cascadingTypes.containsKey(mockedTypeDesc)) {
    cascadingTypes.put(mockedTypeDesc,new MockedTypeCascade(fromMockField,mockedType));
  }
}

Fixed version (ground truth):
@Nonnull MockedTypeCascade add(@Nonnull String mockedTypeDesc,boolean fromMockField,@Nonnull Type mockedType){
  MockedTypeCascade cascade=mockedTypesToCascades.get(mockedType);
  if (cascade == null) {
    cascade=new MockedTypeCascade(fromMockField,mockedType,mockedTypeDesc);
    mockedTypesToCascades.put(mockedType,cascade);
  }
  return cascade;
}
Program: 164675
Project: 164675
Buggy source:
@Nullable private MockedTypeCascade getCascade(@Nonnull String invokedTypeDesc,@Nonnull Class<?> mockedClass){
  Class<?> typeToLookFor=mockedClass;
  do {
    String typeDesc=Type.getInternalName(typeToLookFor);
    if (invokedTypeDesc.equals(typeDesc)) {
      return null;
    }
    MockedTypeCascade cascade=getCascade(typeDesc);
    if (cascade != null) {
      cascade.mockedClass=mockedClass;
      return cascade;
    }
    cascade=getCascadeForInterface(invokedTypeDesc,typeToLookFor);
    if (cascade != null) {
      return cascade;
    }
    typeToLookFor=typeToLookFor.getSuperclass();
  }
 while (typeToLookFor != Object.class);
  return null;
}

Fixed version (ground truth):
@Nullable public MockedTypeCascade getCascade(@Nonnull String mockedTypeDesc,@Nullable Object mockInstance){
  if (mockedTypesToCascades.isEmpty()) {
    return null;
  }
  if (mockInstance != null) {
    MockedTypeCascade cascade=findCascadeForInstance(mockInstance);
    if (cascade != null) {
      return cascade;
    }
  }
  for (  MockedTypeCascade cascade : mockedTypesToCascades.values()) {
    if (cascade.mockedTypeDesc.equals(mockedTypeDesc)) {
      return cascade;
    }
  }
  return null;
}
Program: 164676
Project: 164676
Buggy source:
void clearNonSharedCascadingTypes(){
  if (!cascadingTypes.isEmpty()) {
    Iterator<MockedTypeCascade> itr=cascadingTypes.values().iterator();
    while (itr.hasNext()) {
      MockedTypeCascade cascade=itr.next();
      if (cascade.fromMockField) {
        cascade.discardCascadedMocks();
      }
 else {
        itr.remove();
      }
    }
  }
}

Fixed version (ground truth):
void clearNonSharedCascadingTypes(){
  if (!mockedTypesToCascades.isEmpty()) {
    Iterator<MockedTypeCascade> itr=mockedTypesToCascades.values().iterator();
    while (itr.hasNext()) {
      MockedTypeCascade cascade=itr.next();
      if (cascade.fromMockField) {
        cascade.discardCascadedMocks();
      }
 else {
        itr.remove();
      }
    }
  }
}
Program: 164677
Project: 164677
Buggy source:
public void clear(){
  cascadingTypes.clear();
}

Fixed version (ground truth):
public void clear(){
  mockedTypesToCascades.clear();
}
Program: 164678
Project: 164678
Buggy source:
CascadingTypes(){
  cascadingTypes=new ConcurrentHashMap<String,MockedTypeCascade>(4);
}

Fixed version (ground truth):
CascadingTypes(){
  mockedTypesToCascades=new ConcurrentHashMap<Type,MockedTypeCascade>(4);
}
Program: 164679
Project: 164679
Buggy source:
public void registerMock(boolean injectable,@Nonnull Object mock){
  if (injectable) {
    addInjectableMock(mock);
  }
 else   if (!containsReference(regularMocks,mock)) {
    regularMocks.add(mock);
  }
}

Fixed version (ground truth):
public void registerMock(@Nonnull MockedType mockedType,@Nonnull Object mock){
  if (mockedType.injectable) {
    addInjectableMock(mock);
  }
 else   if (!containsReference(regularMocks,mock)) {
    regularMocks.add(mock);
  }
  Type declaredType=mockedType.getDeclaredType();
  cascadingTypes.addInstance(declaredType,mock);
}
Program: 164680
Project: 164680
Buggy source:
@Nullable private static Object createNewCascadedInstanceOrUseNonCascadedOneIfAvailable(@Nonnull String methodNameAndDesc,@Nonnull Type mockedReturnType){
  InstanceFactory instanceFactory=TestRun.mockFixture().findInstanceFactory(mockedReturnType);
  if (instanceFactory == null) {
    String methodName=methodNameAndDesc.substring(0,methodNameAndDesc.indexOf('('));
    CascadingTypeRedefinition typeRedefinition=new CascadingTypeRedefinition(methodName,mockedReturnType);
    instanceFactory=typeRedefinition.redefineType();
    if (instanceFactory == null) {
      return null;
    }
  }
 else {
    Object lastInstance=instanceFactory.getLastInstance();
    if (lastInstance != null) {
      return lastInstance;
    }
  }
  Object cascadedInstance=instanceFactory.create();
  instanceFactory.clearLastInstance();
  TestRun.getExecutingTest().addInjectableMock(cascadedInstance);
  return cascadedInstance;
}

Fixed version (ground truth):
@Nullable private Object createNewCascadedInstanceOrUseNonCascadedOneIfAvailable(@Nonnull String methodNameAndDesc,@Nonnull Type mockedReturnType){
  InstanceFactory instanceFactory=TestRun.mockFixture().findInstanceFactory(mockedReturnType);
  if (instanceFactory == null) {
    String methodName=methodNameAndDesc.substring(0,methodNameAndDesc.indexOf('('));
    CascadingTypeRedefinition typeRedefinition=new CascadingTypeRedefinition(methodName,mockedReturnType);
    instanceFactory=typeRedefinition.redefineType();
    if (instanceFactory == null) {
      return null;
    }
  }
 else {
    Object lastInstance=instanceFactory.getLastInstance();
    if (lastInstance != null) {
      return lastInstance;
    }
  }
  Object cascadedInstance=instanceFactory.create();
  instanceFactory.clearLastInstance();
  addInstance(cascadedInstance);
  TestRun.getExecutingTest().addInjectableMock(cascadedInstance);
  return cascadedInstance;
}
Program: 164681
Project: 164681
Buggy source:
@Nullable private Object getCascadedInstance(@Nonnull String methodNameAndDesc,@Nonnull String returnTypeInternalName,@Nullable Object mockInstance){
  Type returnType=cascadedTypesAndMocks.get(returnTypeInternalName);
  Class<?> returnClass;
  if (returnType == null) {
    Class<?> cascadingClass=getClassWithCalledMethod();
    Type genericReturnType;
    try {
      genericReturnType=getGenericReturnType(cascadingClass,methodNameAndDesc);
    }
 catch (    NoSuchMethodException ignore) {
      return null;
    }
    Class<?> resolvedReturnType=getClassType(genericReturnType);
    if (resolvedReturnType.isAssignableFrom(cascadingClass)) {
      if (mockInstance != null) {
        return mockInstance;
      }
      returnType=mockedType;
      returnClass=cascadingClass;
    }
 else {
      Object defaultReturnValue=DefaultValues.computeForType(resolvedReturnType);
      if (defaultReturnValue != null) {
        return defaultReturnValue;
      }
      cascadedTypesAndMocks.put(returnTypeInternalName,genericReturnType);
      CASCADING_TYPES.add(returnTypeInternalName,false,genericReturnType);
      returnType=genericReturnType;
      returnClass=resolvedReturnType;
    }
  }
 else {
    returnClass=getClassType(returnType);
  }
  if (getReturnTypeIfCascadingSupportedForIt(returnClass) == null) {
    return null;
  }
  return createNewCascadedInstanceOrUseNonCascadedOneIfAvailable(methodNameAndDesc,returnType);
}

Fixed version (ground truth):
@Nullable private Object getCascadedInstance(@Nonnull String methodNameAndDesc,@Nonnull String returnTypeInternalName,@Nullable Object mockInstance){
  MockedTypeCascade nextLevel=this;
  Type returnType=cascadedTypesAndMocks.get(returnTypeInternalName);
  Class<?> returnClass;
  if (returnType == null) {
    Class<?> cascadingClass=getClassWithCalledMethod();
    Type genericReturnType;
    try {
      genericReturnType=getGenericReturnType(cascadingClass,methodNameAndDesc);
    }
 catch (    NoSuchMethodException ignore) {
      return null;
    }
    Class<?> resolvedReturnType=getClassType(genericReturnType);
    if (resolvedReturnType.isAssignableFrom(cascadingClass)) {
      if (mockInstance != null) {
        return mockInstance;
      }
      returnType=mockedType;
      returnClass=cascadingClass;
    }
 else {
      Object defaultReturnValue=DefaultValues.computeForType(resolvedReturnType);
      if (defaultReturnValue != null) {
        return defaultReturnValue;
      }
      cascadedTypesAndMocks.put(returnTypeInternalName,genericReturnType);
      nextLevel=CASCADING_TYPES.add(returnTypeInternalName,false,genericReturnType);
      returnType=genericReturnType;
      returnClass=resolvedReturnType;
    }
  }
 else {
    nextLevel=CASCADING_TYPES.getCascade(returnType);
    returnClass=getClassType(returnType);
  }
  if (getReturnTypeIfCascadingSupportedForIt(returnClass) == null) {
    return null;
  }
  return nextLevel.createNewCascadedInstanceOrUseNonCascadedOneIfAvailable(methodNameAndDesc,returnType);
}
Program: 164682
Project: 164682
Buggy source:
void discardCascadedMocks(){
  cascadedTypesAndMocks.clear();
}

Fixed version (ground truth):
void discardCascadedMocks(){
  cascadedTypesAndMocks.clear();
  cascadingInstances.clear();
}
Program: 164683
Project: 164683
Buggy source:
MockedTypeCascade(boolean fromMockField,@Nonnull Type mockedType){
  this.fromMockField=fromMockField;
  this.mockedType=mockedType;
  cascadedTypesAndMocks=new ConcurrentHashMap<String,Type>(4);
}

Fixed version (ground truth):
MockedTypeCascade(boolean fromMockField,@Nonnull Type mockedType,@Nonnull String mockedTypeDesc){
  this.fromMockField=fromMockField;
  this.mockedType=mockedType;
  this.mockedTypeDesc=mockedTypeDesc;
  cascadedTypesAndMocks=new ConcurrentHashMap<String,Type>(4);
  cascadingInstances=synchronizedList(new ArrayList<Object>());
}
Program: 164684
Project: 164684
Buggy source:
@Nullable private static Method findInterfaceMethod(@Nonnull Class<?> anInterface,@Nonnull String methodName,@Nonnull Class<?>[] parameterTypes){
  for (  Class<?> superInterface : anInterface.getInterfaces()) {
    try {
      return superInterface.getMethod(methodName,parameterTypes);
    }
 catch (    NoSuchMethodException ignore) {
    }
  }
  return null;
}

Fixed version (ground truth):
@Nullable private static Method findInterfaceMethod(@Nonnull Class<?> aType,@Nonnull String methodName,@Nonnull Class<?>[] parameterTypes){
  for (  Class<?> anInterface : aType.getInterfaces()) {
    try {
      return anInterface.getMethod(methodName,parameterTypes);
    }
 catch (    NoSuchMethodException ignore) {
    }
  }
  return null;
}
Program: 164685
Project: 164685
Buggy source:
@Nonnull private static Method findMethod(@Nonnull Class<?> realClass,@Nonnull String methodName,@Nonnull String methodDesc) throws NoSuchMethodException {
  Class<?>[] parameterTypes=TypeDescriptor.getParameterTypes(methodDesc);
  Class<?> ownerClass=realClass;
  while (true) {
    try {
      Method method=ownerClass.getDeclaredMethod(methodName,parameterTypes);
      if (method.isBridge()) {
        ownerClass=ownerClass.getSuperclass();
        continue;
      }
      return method;
    }
 catch (    NoSuchMethodException e) {
      if (ownerClass.isInterface()) {
        Method interfaceMethod=findInterfaceMethod(ownerClass,methodName,parameterTypes);
        if (interfaceMethod == null) {
          throw e;
        }
        return interfaceMethod;
      }
      ownerClass=ownerClass.getSuperclass();
      if (ownerClass == Object.class) {
        throw e;
      }
    }
  }
}

Fixed version (ground truth):
@Nonnull private static Method findMethod(@Nonnull Class<?> realClass,@Nonnull String methodName,@Nonnull String methodDesc) throws NoSuchMethodException {
  Class<?>[] parameterTypes=TypeDescriptor.getParameterTypes(methodDesc);
  Class<?> ownerClass=realClass;
  while (true) {
    try {
      Method method=ownerClass.getDeclaredMethod(methodName,parameterTypes);
      if (method.isBridge()) {
        ownerClass=ownerClass.getSuperclass();
        continue;
      }
      return method;
    }
 catch (    NoSuchMethodException e) {
      Method interfaceMethod=findInterfaceMethod(ownerClass,methodName,parameterTypes);
      if (interfaceMethod != null) {
        return interfaceMethod;
      }
      ownerClass=ownerClass.getSuperclass();
      if (ownerClass == Object.class) {
        throw e;
      }
    }
  }
}
Program: 164686
Project: 164686
Buggy source:
private boolean isMatchingInstance(@Nonnull Object invokedInstance,@Nullable Boolean matchInstance,@Nonnull Expectation expectation){
}

Fixed version (ground truth):
private boolean isMatchingInstance(@Nonnull Object instance){
  return instanceMap.containsKey(instance) || instanceMap.containsValue(instance) || replacementMap.containsKey(instance)|| replacementMap.containsValue(instance);
}
Program: 164687
Project: 164687
Buggy source:
@Test public void usingStrictAndNotStrictMockedTypes(@Mocked final A a,@Mocked final B b,@Mocked final C c){
  new StrictExpectations(){
{
      new A();
      a.process(input);
      a.result();
      result=42;
    }
  }
;
  new Expectations(){
{
      new B();
      times=1;
      new C();
      times=1;
      b.foo();
      times=input.length;
      c.bar();
      times=input.length;
    }
  }
;
  assertEquals(42,testedMethod());
  new FullVerifications(){
  }
;
}

Fixed version (ground truth):
@Test public void usingStrictAndNotStrictMockedTypes(@Mocked A anyA,@Mocked B anyB,@Mocked C anyC){
  new StrictExpectations(){
{
      A a=new A();
      a.process(input);
      a.result();
      result=42;
    }
  }
;
  new Expectations(){
{
      B b=new B();
      times=1;
      C c=new C();
      times=1;
      b.foo();
      times=input.length;
      c.bar();
      times=input.length;
    }
  }
;
  assertEquals(42,testedMethod());
  new FullVerifications(){
  }
;
}
Program: 164688
Project: 164688
Buggy source:
@Test public void fewerRequirementsUsingNotStrictExpectationsOnly(@Mocked final A a,@Mocked final B b,@Mocked final C c){
  new Expectations(){
{
      new A();
      times=1;
      new B();
      times=1;
      new C();
      times=1;
      a.result();
      result=42;
      b.foo();
      times=input.length;
      c.bar();
      times=input.length;
    }
  }
;
  assertEquals(42,testedMethod());
  new FullVerifications(b,c){
  }
;
}

Fixed version (ground truth):
@Test public void fewerRequirementsUsingNotStrictExpectationsOnly(@Mocked A anyA,@Mocked B anyB,@Mocked C anyC){
  new Expectations(){
{
      A a=new A();
      times=1;
      B b=new B();
      times=1;
      C c=new C();
      times=1;
      a.result();
      result=42;
      b.foo();
      times=input.length;
      c.bar();
      times=input.length;
    }
  }
;
  assertEquals(42,testedMethod());
  new FullVerifications(anyB,anyC){
  }
;
}
Program: 164689
Project: 164689
Buggy source:
@Mock String format(Invocation inv){
  return formats.get(inv.getInvokedInstance());
}

Fixed version (ground truth):
@Mock String format(Invocation inv){
  String pattern=inv.<SimpleDateFormat>getInvokedInstance().toPattern();
  if (DATE_FORMAT.equals(pattern))   return FORMATTED_DATE;
 else   if (TIME_FORMAT.equals(pattern))   return FORMATTED_TIME;
 else   return null;
}
Program: 164690
Project: 164690
Buggy source:
@Test @Ignore("String_Node_Str") public void recordDifferentResultsForInstancesCreatedWithDifferentConstructors(@Mocked final Collaborator anyCol){
  new Expectations(){
{
      anyCol.getValue();
      result=1;
      Collaborator col2=new Collaborator(anyInt);
      col2.getValue();
      result=2;
    }
  }
;
  Collaborator col3=new Collaborator(10);
  int valueFromRecordedConstructor=col3.getValue();
  int valueFromAnyOtherConstructor=new Collaborator().getValue();
  assertEquals(2,valueFromRecordedConstructor);
  assertEquals(1,valueFromAnyOtherConstructor);
}

Fixed version (ground truth):
@Test public void recordDifferentResultsForInstancesCreatedWithDifferentConstructors(@Mocked final Collaborator anyCol){
  new Expectations(){
{
      anyCol.getValue();
      result=1;
      Collaborator col2=new Collaborator(anyInt);
      col2.getValue();
      result=2;
    }
  }
;
  int valueFromRecordedConstructor=new Collaborator(10).getValue();
  int valueFromAnyOtherConstructor=new Collaborator().getValue();
  assertEquals(2,valueFromRecordedConstructor);
  assertEquals(1,valueFromAnyOtherConstructor);
}
Program: 164691
Project: 164691
Buggy source:
@Override public void visit(int version,int access,@Nonnull String name,@Nullable String signature,@Nullable String superName,@Nullable String[] interfaces){
  classExtendsCapturedType=false;
  if (capturedTypeDesc.equals(superName)) {
    classExtendsCapturedType=true;
    throw VisitInterruptedException.INSTANCE;
  }
  boolean haveInterfaces=interfaces != null && interfaces.length > 0;
  if (haveInterfaces) {
    for (    String implementedInterface : interfaces) {
      if (capturedTypeDesc.equals(implementedInterface)) {
        classExtendsCapturedType=true;
        throw VisitInterruptedException.INSTANCE;
      }
    }
  }
  if (superName != null) {
    if (!"String_Node_Str".contains(superName)) {
      searchSuperType(superName);
    }
    if (haveInterfaces) {
      for (      String implementedInterface : interfaces) {
        searchSuperType(implementedInterface);
      }
    }
  }
  throw VisitInterruptedException.INSTANCE;
}

Fixed version (ground truth):
@Override public void visit(int version,int access,@Nonnull String name,@Nullable String signature,@Nullable String superName,@Nullable String[] interfaces){
  classExtendsCapturedType=false;
  if (capturedTypeDesc.equals(superName)) {
    classExtendsCapturedType=true;
    throw VisitInterruptedException.INSTANCE;
  }
  boolean haveInterfaces=interfaces != null && interfaces.length > 0;
  if (haveInterfaces) {
    interruptVisitIfClassImplementsAnInterface(interfaces);
  }
  if (superName != null) {
    if (!"String_Node_Str".contains(superName)) {
      searchSuperType(superName);
    }
    if (haveInterfaces) {
      for (      String implementedInterface : interfaces) {
        searchSuperType(implementedInterface);
      }
    }
  }
  throw VisitInterruptedException.INSTANCE;
}
Program: 164692
Project: 164692
Buggy source:
@Nullable public <C extends CaptureOfImplementations<?>>C getCaptureOfImplementationsIfApplicable(@Nonnull Class<?> baseType){
  if (baseType == capturedType.baseType && typeMetadata != null) {
    return (C)captureOfImplementations;
  }
  return null;
}

Fixed version (ground truth):
@Nullable public <C extends CaptureOfImplementations<?>>C getCaptureOfImplementationsIfApplicable(@Nonnull Class<?> aType){
  if (capturedType.baseType.isAssignableFrom(aType) && typeMetadata != null) {
    return (C)captureOfImplementations;
  }
  return null;
}
Program: 164693
Project: 164693
Buggy source:
@Override void doSomething(){
  throw new IllegalStateException("String_Node_Str");
}

Fixed version (ground truth):
@Override public int doSomething(){
  return -1;
}
Program: 164694
Project: 164694
Buggy source:
boolean isToBeMatchedOnInstance(@Nullable Object mock,@Nonnull String mockNameAndDesc){
  if (mock == null || mockNameAndDesc.charAt(0) == '<') {
    return false;
  }
  if (dynamicMockInstancesToMatch != null && containsReference(dynamicMockInstancesToMatch,mock)) {
    return true;
  }
  if (mockedTypesToMatchOnInstances != null) {
    Class<?> mockedClass=GeneratedClasses.getMockedClass(mock);
    if (containsReference(mockedTypesToMatchOnInstances,mockedClass)) {
      return true;
    }
  }
 else   if (TestRun.getExecutingTest().isInjectableMock(mock)) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
boolean isToBeMatchedOnInstance(@Nullable Object mock,@Nonnull String mockNameAndDesc){
  if (mock == null || mockNameAndDesc.charAt(0) == '<') {
    return false;
  }
  if (dynamicMockInstancesToMatch != null && containsReference(dynamicMockInstancesToMatch,mock)) {
    return true;
  }
  if (mockedTypesToMatchOnInstances != null) {
    Class<?> mockedClass=GeneratedClasses.getMockedClass(mock);
    if (containsReference(mockedTypesToMatchOnInstances,mockedClass)) {
      return true;
    }
  }
  return TestRun.getExecutingTest().isInjectableMock(mock);
}
Program: 164695
Project: 164695
Buggy source:
private void findAllTestedAndInjectableFieldsInTestClassHierarchy(@Nonnull Class<?> testClass){
  Class<?> superclass=testClass.getSuperclass();
  if (superclass.getClassLoader() != null) {
    findAllTestedAndInjectableFieldsInTestClassHierarchy(superclass);
  }
  for (  Field field : testClass.getDeclaredFields()) {
    addAsTestedOrInjectableFieldIfApplicable(field);
  }
}

Fixed version (ground truth):
private void findAllTestedAndInjectableFieldsInTestClassHierarchy(@Nonnull Class<?> testClass){
  Class<?> superclass=testClass.getSuperclass();
  if (superclass.getClassLoader() != null) {
    findAllTestedAndInjectableFieldsInTestClassHierarchy(superclass);
  }
  Field[] fieldsFromTestClass=testClass.getDeclaredFields();
  for (  Field candidateField : fieldsFromTestClass) {
    int fieldModifiers=candidateField.getModifiers();
    if ((fieldModifiers & FIELD_ACCESS_MASK) == 0) {
      addAsTestedOrInjectableFieldIfApplicable(candidateField);
    }
  }
}
Program: 164697
Project: 164697
Buggy source:
AClassMockUp(String value){
  this.value=value;
}

Fixed version (ground truth):
AClassMockUp(int value){
  this.value=value;
}
Program: 164698
Project: 164698
Buggy source:
@Nullable @Override final Object handleInvocation(@Nullable Object mock,int mockAccess,@Nonnull String mockClassDesc,@Nonnull String mockNameAndDesc,@Nullable String genericSignature,boolean withRealImpl,@Nonnull Object[] args){
  if (pendingError != null) {
    recordAndReplay.setErrorThrown(pendingError);
    pendingError=null;
    return null;
  }
  matchInstance=mock != null && (nextInstanceToMatch != null && mock == nextInstanceToMatch || recordAndReplay.executionState.isReplacementInstance(mock,mockNameAndDesc) || isEnumElement(mock));
  ExpectedInvocation currentInvocation=new ExpectedInvocation(mock,mockAccess,mockClassDesc,mockNameAndDesc,matchInstance,genericSignature,args);
  currentInvocation.arguments.setMatchers(argMatchers);
  currentVerification=new Expectation(currentInvocation);
  currentExpectation=null;
  currentVerifiedExpectations.clear();
  findNonStrictExpectation(mock,mockClassDesc,mockNameAndDesc,args);
  argMatchers=null;
  if (matchInstance) {
    nextInstanceToMatch=null;
  }
  if (recordAndReplay.getErrorThrown() != null) {
    return null;
  }
  if (currentExpectation == null) {
    pendingError=currentVerification.invocation.errorForMissingInvocation();
    currentExpectation=currentVerification;
  }
  return currentExpectation.invocation.getDefaultValueForReturnType(this);
}

Fixed version (ground truth):
@Nullable @Override final Object handleInvocation(@Nullable Object mock,int mockAccess,@Nonnull String mockClassDesc,@Nonnull String mockNameAndDesc,@Nullable String genericSignature,boolean withRealImpl,@Nonnull Object[] args){
  if (pendingError != null) {
    recordAndReplay.setErrorThrown(pendingError);
    pendingError=null;
    return null;
  }
  matchInstance=mock != null && (nextInstanceToMatch != null && mock == nextInstanceToMatch || recordAndReplay.executionState.isReplacementInstance(mock,mockNameAndDesc) || isEnumElement(mock));
  ExpectedInvocation currentInvocation=new ExpectedInvocation(mock,mockAccess,mockClassDesc,mockNameAndDesc,matchInstance,genericSignature,args);
  currentInvocation.arguments.setMatchers(argMatchers);
  currentVerification=new Expectation(currentInvocation);
  currentExpectation=null;
  currentVerifiedExpectations.clear();
  findNonStrictExpectation(mock,mockClassDesc,mockNameAndDesc,args);
  argMatchers=null;
  if (matchInstance) {
    nextInstanceToMatch=null;
  }
  if (recordAndReplay.getErrorThrown() != null) {
    return null;
  }
  if (currentExpectation == null) {
    pendingError=currentVerification.invocation.errorForMissingInvocation();
    currentExpectation=currentVerification;
  }
  return currentExpectation.invocation.getDefaultValueForReturnType();
}
Program: 164699
Project: 164699
Buggy source:
@Nullable Object produceResult(@Nullable Object invokedObject,@Nonnull Object[] invocationArgs) throws Throwable {
  if (results == null) {
    return invocation.getDefaultValueForReturnType(null);
  }
  return results.produceResult(invokedObject,invocationArgs);
}

Fixed version (ground truth):
@Nullable Object produceResult(@Nullable Object invokedObject,@Nonnull Object[] invocationArgs) throws Throwable {
  if (results == null) {
    return invocation.getDefaultValueForReturnType();
  }
  return results.produceResult(invokedObject,invocationArgs);
}
Program: 164700
Project: 164700
Buggy source:
@Nullable @Override Object handleInvocation(@Nullable Object mock,int mockAccess,@Nonnull String mockClassDesc,@Nonnull String mockNameAndDesc,@Nullable String genericSignature,boolean withRealImpl,@Nonnull Object[] args) throws Throwable {
  mock=configureMatchingOnMockInstanceIfSpecified(mock);
  ExpectedInvocation invocation=new ExpectedInvocation(mock,mockAccess,mockClassDesc,mockNameAndDesc,matchInstance,genericSignature,args);
  Class<?> callerClass=loadClass(invocation.getCallerClassName());
  if (Expectations.class.isAssignableFrom(callerClass)) {
    boolean nonStrictInvocation=false;
    if (strict) {
      TestRun.getExecutingTest().addStrictMock(mock,matchInstance ? null : mockClassDesc);
    }
 else     if (!matchInstance && invocation.isConstructor()) {
      invocation.replacementInstance=mock;
      getReplacementMap().put(mock,mock);
    }
 else {
      nonStrictInvocation=isInstanceMethodWithStandardBehavior(mock,mockNameAndDesc);
    }
    currentExpectation=new Expectation(this,invocation,strict,nonStrictInvocation);
    if (argMatchers != null) {
      invocation.arguments.setMatchers(argMatchers);
      argMatchers=null;
    }
    recordAndReplay.executionState.addExpectation(currentExpectation,strict);
  }
  return invocation.getDefaultValueForReturnType(this);
}

Fixed version (ground truth):
@Nullable @Override Object handleInvocation(@Nullable Object mock,int mockAccess,@Nonnull String mockClassDesc,@Nonnull String mockNameAndDesc,@Nullable String genericSignature,boolean withRealImpl,@Nonnull Object[] args) throws Throwable {
  mock=configureMatchingOnMockInstanceIfSpecified(mock);
  ExpectedInvocation invocation=new ExpectedInvocation(mock,mockAccess,mockClassDesc,mockNameAndDesc,matchInstance,genericSignature,args);
  Class<?> callerClass=loadClass(invocation.getCallerClassName());
  if (Expectations.class.isAssignableFrom(callerClass)) {
    boolean nonStrictInvocation=false;
    if (strict) {
      TestRun.getExecutingTest().addStrictMock(mock,matchInstance ? null : mockClassDesc);
    }
 else     if (!matchInstance && invocation.isConstructor()) {
      invocation.replacementInstance=mock;
      getReplacementMap().put(mock,mock);
    }
 else {
      nonStrictInvocation=isInstanceMethodWithStandardBehavior(mock,mockNameAndDesc);
    }
    currentExpectation=new Expectation(this,invocation,strict,nonStrictInvocation);
    if (argMatchers != null) {
      invocation.arguments.setMatchers(argMatchers);
      argMatchers=null;
    }
    recordAndReplay.executionState.addExpectation(currentExpectation,strict);
  }
  return invocation.getDefaultValueForReturnType();
}
Program: 164701
Project: 164701
Buggy source:
@Nullable public Object getDefaultValueForReturnType(@Nullable TestOnlyPhase phase){
  if (defaultReturnValue == UNDEFINED_DEFAULT_RETURN) {
    Class<?> resolvedReturnType=getReturnTypeAsResolvedFromClassArgument();
    if (resolvedReturnType != null) {
      defaultReturnValue=DefaultValues.computeForType(resolvedReturnType);
      if (defaultReturnValue == null) {
        String returnTypeDesc='L' + resolvedReturnType.getName().replace('.','/') + ';';
        String mockedTypeDesc=getClassDesc();
        Object cascadedMock=MockedTypeCascade.getMock(mockedTypeDesc,arguments.methodNameAndDesc,instance,returnTypeDesc,resolvedReturnType);
        useCascadedMock(phase,cascadedMock);
      }
      return defaultReturnValue;
    }
    String returnTypeDesc=DefaultValues.getReturnTypeDesc(arguments.methodNameAndDesc);
    defaultReturnValue=DefaultValues.computeForType(returnTypeDesc);
    if (defaultReturnValue == null) {
      produceCascadedInstanceIfApplicable(phase,returnTypeDesc,arguments.genericSignature);
    }
  }
  return defaultReturnValue;
}

Fixed version (ground truth):
@Nullable public Object getDefaultValueForReturnType(){
  if (defaultReturnValue == UNDEFINED_DEFAULT_RETURN) {
    Class<?> resolvedReturnType=getReturnTypeAsResolvedFromClassArgument();
    if (resolvedReturnType != null) {
      defaultReturnValue=DefaultValues.computeForType(resolvedReturnType);
      if (defaultReturnValue == null) {
        String returnTypeDesc='L' + resolvedReturnType.getName().replace('.','/') + ';';
        String mockedTypeDesc=getClassDesc();
        defaultReturnValue=MockedTypeCascade.getMock(mockedTypeDesc,arguments.methodNameAndDesc,instance,returnTypeDesc,resolvedReturnType);
      }
      return defaultReturnValue;
    }
    String returnTypeDesc=DefaultValues.getReturnTypeDesc(arguments.methodNameAndDesc);
    defaultReturnValue=DefaultValues.computeForType(returnTypeDesc);
    if (defaultReturnValue == null) {
      String mockedTypeDesc=getClassDesc();
      defaultReturnValue=MockedTypeCascade.getMock(mockedTypeDesc,arguments.methodNameAndDesc,instance,returnTypeDesc,arguments.genericSignature);
    }
  }
  return defaultReturnValue;
}
Program: 164702
Project: 164702
Buggy source:
private boolean isMatchingMethod(@Nullable Object mock,@Nonnull String invokedMethod){
  if (mock != null && instance != null) {
    String genericSignature=arguments.genericSignature;
    if (genericSignature != null) {
      Class<?> mockedClass=mock.getClass();
      if (mockedClass != instance.getClass()) {
        GenericTypeReflection typeReflection=new GenericTypeReflection(mockedClass,null);
        GenericSignature parsedSignature=typeReflection.parseSignature(genericSignature);
        return parsedSignature.satisfiesSignature(invokedMethod);
      }
    }
  }
  String nameAndDesc=getMethodNameAndDescription();
  int i=0;
  while (true) {
    char c=nameAndDesc.charAt(i);
    if (c != invokedMethod.charAt(i)) {
      return false;
    }
    i++;
    if (c == ')') {
      break;
    }
  }
  int n=invokedMethod.length();
  if (n == nameAndDesc.length()) {
    int j=i;
    while (true) {
      char c=nameAndDesc.charAt(j);
      if (c != invokedMethod.charAt(j)) {
        break;
      }
      j++;
      if (j == n) {
        return true;
      }
    }
  }
  Type rt1=Type.getType(nameAndDesc.substring(i));
  Type rt2=Type.getType(invokedMethod.substring(i));
  return TypeDescriptor.getClassForType(rt2).isAssignableFrom(TypeDescriptor.getClassForType(rt1));
}

Fixed version (ground truth):
private boolean isMatchingMethod(@Nonnull String invokedMethod){
  int returnTypeStartPos=getReturnTypePosition(invokedMethod);
  if (returnTypeStartPos < 0) {
    return false;
  }
  if (haveSameReturnTypes(invokedMethod,returnTypeStartPos)) {
    return true;
  }
  return isReturnTypeOfRecordedMethodAssignableToReturnTypeOfInvokedMethod(invokedMethod,returnTypeStartPos);
}
Program: 164703
Project: 164703
Buggy source:
@Nonnull private Type getGenericReturnType(@Nonnull Class<?> cascadingClass,@Nonnull String methodNameAndDesc) throws NoSuchMethodException {
  Method cascadingMethod=new RealMethodOrConstructor(cascadingClass,methodNameAndDesc).getMember();
  Type genericReturnType=cascadingMethod.getGenericReturnType();
  if (genericReturnType instanceof TypeVariable<?>) {
    genericReturnType=genericReflection.resolveTypeVariable((TypeVariable<?>)genericReturnType);
  }
  return genericReturnType;
}

Fixed version (ground truth):
@Nonnull private Type getGenericReturnType(@Nonnull Class<?> cascadingClass,@Nonnull String methodNameAndDesc) throws NoSuchMethodException {
  Method cascadingMethod=new RealMethodOrConstructor(cascadingClass,methodNameAndDesc).getMember();
  Type genericReturnType=cascadingMethod.getGenericReturnType();
  if (genericReturnType instanceof TypeVariable<?>) {
    genericReturnType=getGenericReflection().resolveTypeVariable((TypeVariable<?>)genericReturnType);
  }
  return genericReturnType;
}
Program: 164704
Project: 164704
Buggy source:
<T extends Bar>T doSomething(){
  return null;
}

Fixed version (ground truth):
<T extends Runnable>T doSomething();
Program: 164705
Project: 164705
Buggy source:
@Nullable private MockedTypeCascade getCascade(@Nonnull String invokedTypeDesc,@Nonnull Class<?> mockedClass){
  Class<?> typeToLookFor=mockedClass;
  do {
    String typeDesc=Type.getInternalName(typeToLookFor);
    if (invokedTypeDesc.equals(typeDesc)) {
      return null;
    }
    MockedTypeCascade cascade=cascadingTypes.get(typeDesc);
    if (cascade != null) {
      cascade.mockedClass=mockedClass;
      return cascade;
    }
    cascade=getCascadeForInterface(invokedTypeDesc,typeToLookFor);
    if (cascade != null) {
      return cascade;
    }
    typeToLookFor=typeToLookFor.getSuperclass();
  }
 while (typeToLookFor != Object.class);
  return null;
}

Fixed version (ground truth):
@Nullable private MockedTypeCascade getCascade(@Nonnull String invokedTypeDesc,@Nonnull Class<?> mockedClass){
  Class<?> typeToLookFor=mockedClass;
  do {
    String typeDesc=Type.getInternalName(typeToLookFor);
    if (invokedTypeDesc.equals(typeDesc)) {
      return null;
    }
    MockedTypeCascade cascade=getCascade(typeDesc);
    if (cascade != null) {
      cascade.mockedClass=mockedClass;
      return cascade;
    }
    cascade=getCascadeForInterface(invokedTypeDesc,typeToLookFor);
    if (cascade != null) {
      return cascade;
    }
    typeToLookFor=typeToLookFor.getSuperclass();
  }
 while (typeToLookFor != Object.class);
  return null;
}
Program: 164706
Project: 164706
Buggy source:
Outer<String>.Inner doSomething(){
  return null;
}

Fixed version (ground truth):
SubB<C> doSomething(){
  return null;
}
Program: 164707
Project: 164707
Buggy source:
@Nonnull public String getSignatureWithResolvedReturnType(){
  String signature=arguments.genericSignature;
  if (signature != null) {
    char firstTypeChar=signature.charAt(signature.indexOf(')') + 1);
    if (firstTypeChar != 'T' && firstTypeChar != '[') {
      return signature;
    }
  }
  return arguments.methodNameAndDesc;
}

Fixed version (ground truth):
@Nonnull public String getSignatureWithResolvedReturnType(){
  String signature=arguments.genericSignature;
  if (signature != null) {
    String classDesc=getClassDesc();
    Class<?> mockedClass=instance != null ? instance.getClass() : ClassLoad.loadByInternalName(classDesc);
    GenericTypeReflection reflection=new GenericTypeReflection(mockedClass,null);
    signature=reflection.resolveReturnType(classDesc,signature);
    char firstTypeChar=signature.charAt(signature.indexOf(')') + 1);
    if (firstTypeChar != 'T' && firstTypeChar != '[') {
      return signature;
    }
  }
  return arguments.methodNameAndDesc;
}
Program: 164708
Project: 164708
Buggy source:
@Override protected void generateMethodBody(int access,@Nonnull String name,@Nonnull String desc,@Nullable String signature,@Nullable String[] exceptions){
  String resolvedSignature=signature;
  if (signature != null) {
    resolvedSignature=mockedTypeInfo.genericTypeMap.resolveReturnType(methodOwner,signature);
  }
  mw=cw.visitMethod(ACC_PUBLIC,name,desc,resolvedSignature,exceptions);
  generateDirectCallToHandler(mw,interfaceName,access,name,desc,resolvedSignature);
  generateReturnWithObjectAtTopOfTheStack(desc);
  mw.visitMaxs(1,0);
}

Fixed version (ground truth):
@Override protected void generateMethodBody(int access,@Nonnull String name,@Nonnull String desc,@Nullable String signature,@Nullable String[] exceptions){
  mw=cw.visitMethod(ACC_PUBLIC,name,desc,signature,exceptions);
  String className=isOverrideOfMethodFromSuperInterface(name,desc) ? interfaceName : methodOwner;
  generateDirectCallToHandler(mw,className,access,name,desc,signature);
  generateReturnWithObjectAtTopOfTheStack(desc);
  mw.visitMaxs(1,0);
}