Program: 155829
Project: 155829
Buggy source:
@SuppressWarnings("String_Node_Str") private static Realm createAndValidate(String absolutePath,byte[] key,boolean validateSchema,boolean autoRefresh){
  int id=absolutePath.hashCode();
  Map<Integer,Integer> localRefCount=referenceCount.get();
  Integer references=localRefCount.get(id);
  if (references == null) {
    references=0;
  }
  Map<Integer,Realm> realms=realmsCache.get();
  Realm realm=realms.get(absolutePath.hashCode());
  if (realm != null) {
    localRefCount.put(id,references + 1);
    referenceCount.set(localRefCount);
    return realm;
  }
  realm=new Realm(absolutePath,key,autoRefresh);
  realms.put(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();
    boolean commitNeeded=false;
    try {
      realm.beginTransaction();
      if (version == UNVERSIONED) {
        realm.setVersion(0);
        commitNeeded=true;
      }
      for (      String className : proxyClasses) {
        String[] splitted=className.split("String_Node_Str");
        String modelClassName=splitted[splitted.length - 1];
        String generatedClassName=getProxyClassName(modelClassName);
        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);
            commitNeeded=true;
          }
 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 {
      if (commitNeeded) {
        realm.commitTransaction();
      }
 else {
        realm.cancelTransaction();
      }
    }
  }
  localRefCount.put(id,references + 1);
  referenceCount.set(localRefCount);
  return realm;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private static Realm createAndValidate(String absolutePath,byte[] key,boolean validateSchema,boolean autoRefresh){
  int id=absolutePath.hashCode();
  Map<Integer,Integer> localRefCount=referenceCount.get();
  Integer references=localRefCount.get(id);
  if (references == null) {
    references=0;
  }
  Map<Integer,Realm> realms=realmsCache.get();
  Realm realm=realms.get(absolutePath.hashCode());
  if (realm != null) {
    localRefCount.put(id,references + 1);
    return realm;
  }
  realm=new Realm(absolutePath,key,autoRefresh);
  realms.put(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();
    boolean commitNeeded=false;
    try {
      realm.beginTransaction();
      if (version == UNVERSIONED) {
        realm.setVersion(0);
        commitNeeded=true;
      }
      for (      String className : proxyClasses) {
        String[] splitted=className.split("String_Node_Str");
        String modelClassName=splitted[splitted.length - 1];
        String generatedClassName=getProxyClassName(modelClassName);
        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);
            commitNeeded=true;
          }
 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 {
      if (commitNeeded) {
        realm.commitTransaction();
      }
 else {
        realm.cancelTransaction();
      }
    }
  }
  localRefCount.put(id,references + 1);
  return realm;
}