com.esotericsoftware.reflectasm.ConstructorAccess Java Examples

The following examples show how to use com.esotericsoftware.reflectasm.ConstructorAccess. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TableInfo.java    From litchi with Apache License 2.0 6 votes vote down vote up
public static TableInfo valueOf(Class<? extends Table> clazz, TableName tableName) {
    TableInfo tableInfo = new TableInfo();
    tableInfo.clazz = clazz;
    tableInfo.tableName = tableName;

    tableInfo.classAccess = ConstructorAccess.get(clazz);
    tableInfo.fieldAccess = FieldAccess.get(clazz);

    //reflect column
    tableInfo.reflectColumn(clazz.getDeclaredFields());

    if (StringUtils.isBlank(tableInfo.pkName)) {
        LOGGER.error(tableName.tableName() + "实体缺少主键");
    }
    return tableInfo;
}
 
Example #2
Source File: ConstructorAccessBenchmark.java    From reflectasm with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public ConstructorAccessBenchmark () throws Exception {
	int count = 1000000;
	Object[] dontCompileMeAway = new Object[count];

	Class type = SomeClass.class;
	ConstructorAccess<SomeClass> access = ConstructorAccess.get(type);

	for (int i = 0; i < 100; i++)
		for (int ii = 0; ii < count; ii++)
			dontCompileMeAway[ii] = access.newInstance();
	for (int i = 0; i < 100; i++)
		for (int ii = 0; ii < count; ii++)
			dontCompileMeAway[ii] = type.newInstance();
	warmup = false;

	for (int i = 0; i < 100; i++) {
		start();
		for (int ii = 0; ii < count; ii++)
			dontCompileMeAway[ii] = access.newInstance();
		end("ConstructorAccess");
	}
	for (int i = 0; i < 100; i++) {
		start();
		for (int ii = 0; ii < count; ii++)
			dontCompileMeAway[ii] = type.newInstance();
		end("Reflection");
	}

	chart("Constructor");
}