Program: 155852
Project: 155852
Buggy source:
private static Realm createAndValidate(String absolutePath,boolean validateSchema){
  Map<String,Realm> realms=realmsCache.get();
  Realm realm=realms.get(absolutePath);
  if (realm == null) {
    realm=new Realm(absolutePath);
    realms.put(absolutePath,realm);
    realmsCache.set(realms);
  }
  if (validateSchema) {
    if (!validatedPaths.contains(absolutePath)) {
      Class<?> validationClass;
      try {
        validationClass=Class.forName("String_Node_Str");
      }
 catch (      ClassNotFoundException e) {
        throw new RealmException("String_Node_Str");
      }
      Method getProxyClassesMethod;
      try {
        getProxyClassesMethod=validationClass.getMethod("String_Node_Str");
      }
 catch (      NoSuchMethodException e) {
        throw new RealmException("String_Node_Str");
      }
      List<String> proxyClasses;
      try {
        proxyClasses=(List<String>)getProxyClassesMethod.invoke(null);
      }
 catch (      IllegalAccessException e) {
        throw new RealmException("String_Node_Str");
      }
catch (      InvocationTargetException e) {
        throw new RealmException("String_Node_Str");
      }
      long version=realm.getVersion();
      try {
        if (version == UNVERSIONED) {
          realm.beginTransaction();
          realm.setVersion(0);
        }
        for (        String className : proxyClasses) {
          String modelClassName=Iterables.getLast(Splitter.on("String_Node_Str").split(className));
          String generatedClassName="String_Node_Str" + modelClassName + "String_Node_Str";
          Class<?> generatedClass;
          try {
            generatedClass=Class.forName(generatedClassName);
          }
 catch (          ClassNotFoundException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
          }
          if (version == UNVERSIONED) {
            Method initTableMethod;
            try {
              initTableMethod=generatedClass.getMethod("String_Node_Str",new Class[]{ImplicitTransaction.class});
            }
 catch (            NoSuchMethodException e) {
              throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
            }
            try {
              initTableMethod.invoke(null,realm.transaction);
            }
 catch (            IllegalAccessException e) {
              throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
            }
catch (            InvocationTargetException e) {
              throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
            }
          }
          Method fieldNamesMethod;
          try {
            fieldNamesMethod=generatedClass.getMethod("String_Node_Str");
          }
 catch (          NoSuchMethodException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
          }
          List<String> fieldNames;
          try {
            fieldNames=(List<String>)fieldNamesMethod.invoke(null);
          }
 catch (          IllegalAccessException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
          }
catch (          InvocationTargetException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
          }
          Table table=realm.transaction.getTable(TABLE_PREFIX + modelClassName);
          for (          String fieldName : fieldNames) {
            long columnIndex=table.getColumnIndex(fieldName);
            if (columnIndex == -1) {
              throw new RealmException("String_Node_Str");
            }
            columnIndices.put(modelClassName,fieldName,columnIndex);
          }
          Method validateMethod;
          try {
            validateMethod=generatedClass.getMethod("String_Node_Str",new Class[]{ImplicitTransaction.class});
          }
 catch (          NoSuchMethodException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
          }
          try {
            validateMethod.invoke(null,realm.transaction);
          }
 catch (          IllegalAccessException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
          }
catch (          InvocationTargetException e) {
            throw new RealmMigrationNeededException(e.getMessage());
          }
        }
        validatedPaths.add(absolutePath);
      }
  finally {
        if (version == UNVERSIONED) {
          realm.commitTransaction();
        }
      }
    }
  }
  return realm;
}

Fixed version (ground truth):
private static Realm createAndValidate(String absolutePath,boolean validateSchema){
  Map<String,Realm> realms=realmsCache.get();
  Realm realm=realms.get(absolutePath);
  if (realm == null) {
    realm=new Realm(absolutePath);
    realms.put(absolutePath,realm);
    realmsCache.set(realms);
  }
  if (validateSchema) {
    if (!validatedPaths.contains(absolutePath)) {
      Class<?> validationClass;
      try {
        validationClass=Class.forName("String_Node_Str");
      }
 catch (      ClassNotFoundException e) {
        throw new RealmException("String_Node_Str");
      }
      Method getProxyClassesMethod;
      try {
        getProxyClassesMethod=validationClass.getMethod("String_Node_Str");
      }
 catch (      NoSuchMethodException e) {
        throw new RealmException("String_Node_Str");
      }
      List<String> proxyClasses;
      try {
        proxyClasses=(List<String>)getProxyClassesMethod.invoke(null);
      }
 catch (      IllegalAccessException e) {
        throw new RealmException("String_Node_Str");
      }
catch (      InvocationTargetException e) {
        throw new RealmException("String_Node_Str");
      }
      long version=realm.getVersion();
      try {
        realm.beginTransaction();
        if (version == UNVERSIONED) {
          realm.setVersion(0);
        }
        for (        String className : proxyClasses) {
          String modelClassName=Iterables.getLast(Splitter.on("String_Node_Str").split(className));
          String generatedClassName="String_Node_Str" + modelClassName + "String_Node_Str";
          Class<?> generatedClass;
          try {
            generatedClass=Class.forName(generatedClassName);
          }
 catch (          ClassNotFoundException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
          }
          if (version == UNVERSIONED) {
            Method initTableMethod;
            try {
              initTableMethod=generatedClass.getMethod("String_Node_Str",new Class[]{ImplicitTransaction.class});
            }
 catch (            NoSuchMethodException e) {
              throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
            }
            try {
              initTableMethod.invoke(null,realm.transaction);
            }
 catch (            IllegalAccessException e) {
              throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
            }
catch (            InvocationTargetException e) {
              throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
            }
          }
          Method validateMethod;
          try {
            validateMethod=generatedClass.getMethod("String_Node_Str",new Class[]{ImplicitTransaction.class});
          }
 catch (          NoSuchMethodException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
          }
          try {
            validateMethod.invoke(null,realm.transaction);
          }
 catch (          IllegalAccessException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
          }
catch (          InvocationTargetException e) {
            throw new RealmMigrationNeededException(e.getMessage());
          }
          Method fieldNamesMethod;
          try {
            fieldNamesMethod=generatedClass.getMethod("String_Node_Str");
          }
 catch (          NoSuchMethodException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
          }
          List<String> fieldNames;
          try {
            fieldNames=(List<String>)fieldNamesMethod.invoke(null);
          }
 catch (          IllegalAccessException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
          }
catch (          InvocationTargetException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str");
          }
          Table table=realm.transaction.getTable(TABLE_PREFIX + modelClassName);
          for (          String fieldName : fieldNames) {
            long columnIndex=table.getColumnIndex(fieldName);
            if (columnIndex == -1) {
              throw new RealmMigrationNeededException("String_Node_Str" + fieldName + "String_Node_Str"+ modelClassName+ "String_Node_Str");
            }
            columnIndices.put(modelClassName,fieldName,columnIndex);
          }
        }
        validatedPaths.add(absolutePath);
      }
  finally {
        realm.commitTransaction();
      }
    }
  }
  return realm;
}