Program: 90433
Project: 90433
Buggy source:
/** 
 * 通过翻身将class转换为DBTable对象
 */
protected DBTable converTo(Class<?> defClass){
  if (defClass == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Class<?> clazz;
  try {
    clazz=defClass.newInstance().getClass();
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  Table annoTable=clazz.getAnnotation(Table.class);
  if (annoTable == null) {
    throw new IllegalArgumentException(clazz + "String_Node_Str");
  }
  String tableName=StringUtil.isBlank(annoTable.name()) ? clazz.getSimpleName() : annoTable.name();
  DBTable table=new DBTable(tableName.toLowerCase());
  String cluster=annoTable.cluster();
  if (StringUtil.isBlank(cluster)) {
    throw new IllegalArgumentException(clazz + "String_Node_Str");
  }
  table.setCluster(cluster);
  String shardingBy=annoTable.shardingBy();
  table.setShardingBy(shardingBy);
  int shardingNum=annoTable.shardingNum();
  table.setShardingNum(shardingNum);
  boolean isCache=annoTable.cache();
  table.setCache(isCache);
  _parseDBIndex(table,clazz);
  DBTablePK primaryKey=null;
  DBTableColumn column=null;
  org.pinus4j.entity.annotations.Field dbField=null;
  PrimaryKey pk=null;
  UpdateTime updateTime=null;
  DateTime datetime=null;
  for (  Field f : clazz.getDeclaredFields()) {
    datetime=f.getAnnotation(DateTime.class);
    if (datetime != null) {
      if (f.getType() != Date.class) {
        throw new IllegalArgumentException(clazz + "String_Node_Str" + f.getName()+ "String_Node_Str"+ f.getType()+ "String_Node_Str");
      }
      String fieldName=f.getName();
      if (StringUtil.isNotBlank(datetime.name())) {
        fieldName=datetime.name();
      }
      BeansUtil.putAliasField(clazz,fieldName,f);
      column=new DBTableColumn();
      column.setField(fieldName);
      column.setType(DataTypeBind.DATETIME.getDBType());
      column.setHasDefault(datetime.hasDefault());
      if (column.isHasDefault())       column.setDefaultValue(DataTypeBind.DATETIME.getDefaultValue());
      column.setComment(datetime.comment());
      table.addColumn(column);
    }
    updateTime=f.getAnnotation(UpdateTime.class);
    if (updateTime != null) {
      if (f.getType() != java.sql.Timestamp.class) {
        throw new IllegalArgumentException(clazz + "String_Node_Str" + f.getName()+ "String_Node_Str"+ f.getType()+ "String_Node_Str");
      }
      String fieldName=f.getName();
      if (StringUtil.isNotBlank(updateTime.name())) {
        fieldName=updateTime.name();
      }
      BeansUtil._aliasFieldCache.put(clazz.getName() + fieldName,f);
      column=new DBTableColumn();
      column.setField(fieldName);
      column.setType(DataTypeBind.UPDATETIME.getDBType());
      column.setHasDefault(true);
      column.setDefaultValue(DataTypeBind.UPDATETIME.getDefaultValue());
      column.setComment(updateTime.comment());
      table.addColumn(column);
    }
    dbField=f.getAnnotation(org.pinus4j.entity.annotations.Field.class);
    if (dbField != null) {
      if (f.getType() == java.sql.Timestamp.class) {
        throw new IllegalArgumentException(clazz + "String_Node_Str" + f.getName()+ "String_Node_Str");
      }
      String fieldName=f.getName();
      if (StringUtil.isNotBlank(dbField.name())) {
        fieldName=dbField.name();
      }
      BeansUtil._aliasFieldCache.put(clazz.getName() + fieldName,f);
      boolean isCanNull=dbField.isCanNull();
      int length=_getLength(f,dbField.length());
      boolean hasDefault=dbField.hasDefault();
      column=new DBTableColumn();
      column.setField(fieldName);
      column.setType(DataTypeBind.getEnum(f.getType()).getDBType());
      column.setCanNull(isCanNull);
      column.setLength(length);
      column.setHasDefault(hasDefault);
      column.setComment(dbField.comment());
      if (column.isHasDefault())       column.setDefaultValue(DataTypeBind.getEnum(f.getType()).getDefaultValue());
      if (column.getType().equals(DataTypeBind.STRING.getDBType()) && column.getLength() > Const.COLUMN_TEXT_LENGTH) {
        column.setType(DataTypeBind.TEXT.getDBType());
        column.setHasDefault(false);
        column.setLength(0);
        column.setDefaultValue(DataTypeBind.TEXT.getDefaultValue());
      }
      if (column.getType().equals(DataTypeBind.BOOL.getDBType())) {
        column.setLength(1);
      }
      table.addColumn(column);
    }
    pk=f.getAnnotation(PrimaryKey.class);
    if (pk != null) {
      String fieldName=f.getName();
      if (StringUtil.isNotBlank(pk.name())) {
        fieldName=pk.name();
      }
      BeansUtil._aliasFieldCache.put(clazz.getName() + fieldName,f);
      primaryKey=new DBTablePK();
      primaryKey.setField(fieldName);
      DataTypeBind dbType=DataTypeBind.getEnum(f.getType());
      primaryKey.setType(dbType.getDBType());
      int length=_getLength(f,pk.length());
      primaryKey.setLength(length);
      primaryKey.setComment(pk.comment());
      primaryKey.setAutoIncrement(pk.isAutoIncrement());
      table.addPrimaryKey(primaryKey);
      table.addColumn(primaryKey.toTableColumn());
    }
  }
  table.checkPrimaryKey();
  if (table.getColumns().isEmpty()) {
    throw new IllegalStateException(clazz + "String_Node_Str" + defClass);
  }
  return table;
}

Fixed version (ground truth):
/** 
 * 通过翻身将class转换为DBTable对象
 */
protected DBTable converTo(Class<?> defClass){
  if (defClass == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Class<?> clazz;
  try {
    clazz=defClass.newInstance().getClass();
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  Table annoTable=clazz.getAnnotation(Table.class);
  if (annoTable == null) {
    throw new IllegalArgumentException(clazz + "String_Node_Str");
  }
  String tableName=StringUtil.isBlank(annoTable.name()) ? clazz.getSimpleName() : annoTable.name();
  DBTable table=new DBTable(tableName.toLowerCase());
  String cluster=annoTable.cluster();
  if (StringUtil.isBlank(cluster)) {
    throw new IllegalArgumentException(clazz + "String_Node_Str");
  }
  table.setCluster(cluster);
  String shardingBy=annoTable.shardingBy();
  table.setShardingBy(shardingBy);
  int shardingNum=annoTable.shardingNum();
  table.setShardingNum(shardingNum);
  boolean isCache=annoTable.cache();
  table.setCache(isCache);
  _parseDBIndex(table,clazz);
  DBTablePK primaryKey=null;
  DBTableColumn column=null;
  org.pinus4j.entity.annotations.Field dbField=null;
  PrimaryKey pk=null;
  UpdateTime updateTime=null;
  DateTime datetime=null;
  for (  Field f : clazz.getDeclaredFields()) {
    datetime=f.getAnnotation(DateTime.class);
    if (datetime != null) {
      if (f.getType() != Date.class) {
        throw new IllegalArgumentException(clazz + "String_Node_Str" + f.getName()+ "String_Node_Str"+ f.getType()+ "String_Node_Str");
      }
      String fieldName=f.getName();
      if (StringUtil.isNotBlank(datetime.name())) {
        fieldName=datetime.name();
      }
      BeansUtil.putAliasField(clazz,fieldName,f);
      column=new DBTableColumn();
      column.setField(fieldName);
      column.setType(DataTypeBind.DATETIME.getDBType());
      column.setHasDefault(datetime.hasDefault());
      if (column.isHasDefault())       column.setDefaultValue(DataTypeBind.DATETIME.getDefaultValue());
      column.setComment(datetime.comment());
      table.addColumn(column);
    }
    updateTime=f.getAnnotation(UpdateTime.class);
    if (updateTime != null) {
      if (f.getType() != java.sql.Timestamp.class) {
        throw new IllegalArgumentException(clazz + "String_Node_Str" + f.getName()+ "String_Node_Str"+ f.getType()+ "String_Node_Str");
      }
      String fieldName=f.getName();
      if (StringUtil.isNotBlank(updateTime.name())) {
        fieldName=updateTime.name();
      }
      BeansUtil._aliasFieldCache.put(clazz.getName() + fieldName,f);
      column=new DBTableColumn();
      column.setField(fieldName);
      column.setType(DataTypeBind.UPDATETIME.getDBType());
      column.setHasDefault(true);
      column.setDefaultValue(DataTypeBind.UPDATETIME.getDefaultValue());
      column.setComment(updateTime.comment());
      table.addColumn(column);
    }
    dbField=f.getAnnotation(org.pinus4j.entity.annotations.Field.class);
    if (dbField != null) {
      if (f.getType() == java.sql.Timestamp.class) {
        throw new IllegalArgumentException(clazz + "String_Node_Str" + f.getName()+ "String_Node_Str");
      }
      if (f.getType() == java.util.Date.class) {
        throw new IllegalArgumentException(clazz + "String_Node_Str" + f.getName()+ "String_Node_Str");
      }
      String fieldName=f.getName();
      if (StringUtil.isNotBlank(dbField.name())) {
        fieldName=dbField.name();
      }
      BeansUtil._aliasFieldCache.put(clazz.getName() + fieldName,f);
      boolean isCanNull=dbField.isCanNull();
      int length=_getLength(f,dbField.length());
      boolean hasDefault=dbField.hasDefault();
      column=new DBTableColumn();
      column.setField(fieldName);
      column.setType(DataTypeBind.getEnum(f.getType()).getDBType());
      column.setCanNull(isCanNull);
      column.setLength(length);
      column.setHasDefault(hasDefault);
      column.setComment(dbField.comment());
      if (column.isHasDefault())       column.setDefaultValue(DataTypeBind.getEnum(f.getType()).getDefaultValue());
      if (column.getType().equals(DataTypeBind.STRING.getDBType()) && column.getLength() > Const.COLUMN_TEXT_LENGTH) {
        column.setType(DataTypeBind.TEXT.getDBType());
        column.setHasDefault(false);
        column.setLength(0);
        column.setDefaultValue(DataTypeBind.TEXT.getDefaultValue());
      }
      if (column.getType().equals(DataTypeBind.BOOL.getDBType())) {
        column.setLength(1);
      }
      table.addColumn(column);
    }
    pk=f.getAnnotation(PrimaryKey.class);
    if (pk != null) {
      String fieldName=f.getName();
      if (StringUtil.isNotBlank(pk.name())) {
        fieldName=pk.name();
      }
      BeansUtil._aliasFieldCache.put(clazz.getName() + fieldName,f);
      primaryKey=new DBTablePK();
      primaryKey.setField(fieldName);
      DataTypeBind dbType=DataTypeBind.getEnum(f.getType());
      primaryKey.setType(dbType.getDBType());
      int length=_getLength(f,pk.length());
      primaryKey.setLength(length);
      primaryKey.setComment(pk.comment());
      primaryKey.setAutoIncrement(pk.isAutoIncrement());
      table.addPrimaryKey(primaryKey);
      table.addColumn(primaryKey.toTableColumn());
    }
  }
  table.checkPrimaryKey();
  if (table.getColumns().isEmpty()) {
    throw new IllegalStateException(clazz + "String_Node_Str" + defClass);
  }
  return table;
}