Program: 155848
Project: 155848
Buggy source:
private static Realm createAndValidate(String absolutePath,byte[] key,boolean validateSchema,boolean autoRefresh){
  Map<Integer,Realm> realms=realmsCache.get();
  Realm realm=realms.get(absolutePath);
  if (realm != null) {
    return realm;
  }
  realm=new Realm(absolutePath,key,autoRefresh);
  realms.put(new Integer(absolutePath.hashCode()),realm);
  realmsCache.set(realms);
  if (validateSchema) {
    Class<?> validationClass;
    try {
      validationClass=Class.forName("String_Node_Str");
    }
 catch (    ClassNotFoundException e) {
      throw new RealmException("String_Node_Str" + APT_NOT_EXECUTED_MESSAGE);
    }
    Method getProxyClassesMethod;
    try {
      getProxyClassesMethod=validationClass.getMethod("String_Node_Str");
    }
 catch (    NoSuchMethodException e) {
      throw new RealmException("String_Node_Str" + APT_NOT_EXECUTED_MESSAGE);
    }
    List<String> proxyClasses;
    try {
      proxyClasses=(List<String>)getProxyClassesMethod.invoke(null);
    }
 catch (    IllegalAccessException e) {
      throw new RealmException("String_Node_Str" + APT_NOT_EXECUTED_MESSAGE);
    }
catch (    InvocationTargetException e) {
      throw new RealmException("String_Node_Str" + APT_NOT_EXECUTED_MESSAGE);
    }
    long version=realm.getVersion();
    try {
      realm.beginTransaction();
      if (version == UNVERSIONED) {
        realm.setVersion(0);
      }
      for (      String className : proxyClasses) {
        String[] splitted=className.split("String_Node_Str");
        String modelClassName=splitted[splitted.length - 1];
        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"+ APT_NOT_EXECUTED_MESSAGE);
        }
        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"+ APT_NOT_EXECUTED_MESSAGE);
          }
          try {
            initTableMethod.invoke(null,realm.transaction);
          }
 catch (          IllegalAccessException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str"+ APT_NOT_EXECUTED_MESSAGE);
          }
catch (          InvocationTargetException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str"+ APT_NOT_EXECUTED_MESSAGE);
          }
        }
        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"+ APT_NOT_EXECUTED_MESSAGE);
        }
        try {
          validateMethod.invoke(null,realm.transaction);
        }
 catch (        IllegalAccessException e) {
          throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str"+ APT_NOT_EXECUTED_MESSAGE);
        }
catch (        InvocationTargetException e) {
          throw new RealmMigrationNeededException(e.getMessage(),e);
        }
        Method fieldNamesMethod;
        try {
          fieldNamesMethod=generatedClass.getMethod("String_Node_Str");
        }
 catch (        NoSuchMethodException e) {
          throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str"+ APT_NOT_EXECUTED_MESSAGE);
        }
        List<String> fieldNames;
        try {
          fieldNames=(List<String>)fieldNamesMethod.invoke(null);
        }
 catch (        IllegalAccessException e) {
          throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str"+ APT_NOT_EXECUTED_MESSAGE);
        }
catch (        InvocationTargetException e) {
          throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str"+ APT_NOT_EXECUTED_MESSAGE);
        }
        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");
          }
          Map<String,Long> innerMap=columnIndices.get(modelClassName);
          if (innerMap == null) {
            innerMap=new HashMap<String,Long>();
          }
          innerMap.put(fieldName,columnIndex);
          columnIndices.put(modelClassName,innerMap);
        }
      }
    }
  finally {
      realm.commitTransaction();
    }
  }
  return realm;
}

Fixed version (ground truth):
private static Realm createAndValidate(String absolutePath,byte[] key,boolean validateSchema,boolean autoRefresh){
  Map<Integer,Realm> realms=realmsCache.get();
  Realm realm=realms.get(absolutePath.hashCode());
  if (realm != null) {
    return realm;
  }
  realm=new Realm(absolutePath,key,autoRefresh);
  realms.put(new Integer(absolutePath.hashCode()),realm);
  realmsCache.set(realms);
  if (validateSchema) {
    Class<?> validationClass;
    try {
      validationClass=Class.forName("String_Node_Str");
    }
 catch (    ClassNotFoundException e) {
      throw new RealmException("String_Node_Str" + APT_NOT_EXECUTED_MESSAGE);
    }
    Method getProxyClassesMethod;
    try {
      getProxyClassesMethod=validationClass.getMethod("String_Node_Str");
    }
 catch (    NoSuchMethodException e) {
      throw new RealmException("String_Node_Str" + APT_NOT_EXECUTED_MESSAGE);
    }
    List<String> proxyClasses;
    try {
      proxyClasses=(List<String>)getProxyClassesMethod.invoke(null);
    }
 catch (    IllegalAccessException e) {
      throw new RealmException("String_Node_Str" + APT_NOT_EXECUTED_MESSAGE);
    }
catch (    InvocationTargetException e) {
      throw new RealmException("String_Node_Str" + APT_NOT_EXECUTED_MESSAGE);
    }
    long version=realm.getVersion();
    try {
      realm.beginTransaction();
      if (version == UNVERSIONED) {
        realm.setVersion(0);
      }
      for (      String className : proxyClasses) {
        String[] splitted=className.split("String_Node_Str");
        String modelClassName=splitted[splitted.length - 1];
        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"+ APT_NOT_EXECUTED_MESSAGE);
        }
        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"+ APT_NOT_EXECUTED_MESSAGE);
          }
          try {
            initTableMethod.invoke(null,realm.transaction);
          }
 catch (          IllegalAccessException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str"+ APT_NOT_EXECUTED_MESSAGE);
          }
catch (          InvocationTargetException e) {
            throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str"+ APT_NOT_EXECUTED_MESSAGE);
          }
        }
        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"+ APT_NOT_EXECUTED_MESSAGE);
        }
        try {
          validateMethod.invoke(null,realm.transaction);
        }
 catch (        IllegalAccessException e) {
          throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str"+ APT_NOT_EXECUTED_MESSAGE);
        }
catch (        InvocationTargetException e) {
          throw new RealmMigrationNeededException(e.getMessage(),e);
        }
        Method fieldNamesMethod;
        try {
          fieldNamesMethod=generatedClass.getMethod("String_Node_Str");
        }
 catch (        NoSuchMethodException e) {
          throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str"+ APT_NOT_EXECUTED_MESSAGE);
        }
        List<String> fieldNames;
        try {
          fieldNames=(List<String>)fieldNamesMethod.invoke(null);
        }
 catch (        IllegalAccessException e) {
          throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str"+ APT_NOT_EXECUTED_MESSAGE);
        }
catch (        InvocationTargetException e) {
          throw new RealmException("String_Node_Str" + generatedClassName + "String_Node_Str"+ APT_NOT_EXECUTED_MESSAGE);
        }
        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");
          }
          Map<String,Long> innerMap=columnIndices.get(modelClassName);
          if (innerMap == null) {
            innerMap=new HashMap<String,Long>();
          }
          innerMap.put(fieldName,columnIndex);
          columnIndices.put(modelClassName,innerMap);
        }
      }
    }
  finally {
      realm.commitTransaction();
    }
  }
  return realm;
}