This commit is contained in:
kamhung
2015-12-04 15:55:25 +08:00
parent 3aa995bf8b
commit 3966da6b7a

View File

@@ -53,6 +53,7 @@ public interface Attribute<T, F> {
public static <T, F> Attribute<T, F> create(String fieldname, final Field field) { public static <T, F> Attribute<T, F> create(String fieldname, final Field field) {
return create((Class<T>) field.getDeclaringClass(), fieldname, field, null, null); return create((Class<T>) field.getDeclaringClass(), fieldname, field, null, null);
} }
/** /**
* 根据一个Class和field名生成 Attribute 对象。 * 根据一个Class和field名生成 Attribute 对象。
* *
@@ -230,6 +231,7 @@ public interface Attribute<T, F> {
mv.visitFieldInsn(GETFIELD, interName, field.getName(), Type.getDescriptor(pcolumn)); mv.visitFieldInsn(GETFIELD, interName, field.getName(), Type.getDescriptor(pcolumn));
if (pcolumn != column) { if (pcolumn != column) {
mv.visitMethodInsn(INVOKESTATIC, columnName, "valueOf", "(" + Type.getDescriptor(pcolumn) + ")" + columnDesc, false); mv.visitMethodInsn(INVOKESTATIC, columnName, "valueOf", "(" + Type.getDescriptor(pcolumn) + ")" + columnDesc, false);
m = 2;
} }
} }
} else { } else {
@@ -257,6 +259,7 @@ public interface Attribute<T, F> {
try { try {
java.lang.reflect.Method pm = column.getMethod(pcolumn.getSimpleName() + "Value"); java.lang.reflect.Method pm = column.getMethod(pcolumn.getSimpleName() + "Value");
mv.visitMethodInsn(INVOKEVIRTUAL, columnName, pm.getName(), Type.getMethodDescriptor(pm), false); mv.visitMethodInsn(INVOKEVIRTUAL, columnName, pm.getName(), Type.getMethodDescriptor(pm), false);
m = 3;
} catch (Exception ex) { } catch (Exception ex) {
throw new RuntimeException(ex); //不可能会发生 throw new RuntimeException(ex); //不可能会发生
} }