本文整理汇总了Java中com.alibaba.fastjson.util.FieldInfo.getMethod方法的典型用法代码示例。如果您正苦于以下问题:Java FieldInfo.getMethod方法的具体用法?Java FieldInfo.getMethod怎么用?Java FieldInfo.getMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.util.FieldInfo
的用法示例。
在下文中一共展示了FieldInfo.getMethod方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _set
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _set(Context context, MethodVisitor mw, FieldInfo fieldInfo) {
if (fieldInfo.getMethod() != null) {
mw.visitMethodInsn(182, ASMUtils.getType(fieldInfo.getDeclaringClass()), fieldInfo.getMethod().getName(), ASMUtils.getDesc(fieldInfo.getMethod()));
if (!fieldInfo.getMethod().getReturnType().equals(Void.TYPE)) {
mw.visitInsn(87);
return;
}
return;
}
mw.visitFieldInsn(181, ASMUtils.getType(fieldInfo.getDeclaringClass()), fieldInfo.getField().getName(), ASMUtils.getDesc(fieldInfo.getFieldClass()));
}
示例2: _get
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _get(MethodVisitor mw, Context context, FieldInfo property) {
Method method = property.getMethod();
if (method != null) {
mw.visitVarInsn(25, context.var("entity"));
mw.visitMethodInsn(182, ASMUtils.getType(method.getDeclaringClass()), method.getName(), ASMUtils.getDesc(method));
return;
}
mw.visitVarInsn(25, context.var("entity"));
mw.visitFieldInsn(180, ASMUtils.getType(property.getDeclaringClass()), property.getField().getName(), ASMUtils.getDesc(property.getFieldClass()));
}
示例3: _set
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _set(Context context, MethodVisitor mw, FieldInfo fieldInfo) {
if (fieldInfo.getMethod() != null) {
mw.visitMethodInsn(INVOKEVIRTUAL, getType(fieldInfo.getDeclaringClass()), fieldInfo.getMethod().getName(),
getDesc(fieldInfo.getMethod()));
if (!fieldInfo.getMethod().getReturnType().equals(Void.TYPE)) {
mw.visitInsn(POP);
}
} else {
mw.visitFieldInsn(PUTFIELD, getType(fieldInfo.getDeclaringClass()), fieldInfo.getField().getName(),
getDesc(fieldInfo.getFieldClass()));
}
}
示例4: _get
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _get(MethodVisitor mw, Context context, FieldInfo property) {
Method method = property.getMethod();
if (method != null) {
mw.visitVarInsn(ALOAD, context.var("entity"));
mw.visitMethodInsn(INVOKEVIRTUAL, getType(method.getDeclaringClass()), method.getName(), getDesc(method));
} else {
mw.visitVarInsn(ALOAD, context.var("entity"));
mw.visitFieldInsn(GETFIELD, getType(property.getDeclaringClass()), property.getField().getName(),
getDesc(property.getFieldClass()));
}
}
示例5: genBatchSet
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void genBatchSet(List<FieldInfo> fieldList, boolean flag) throws IOException {
for (int i = 0, size = fieldList.size(); i < size; ++i) {
FieldInfo fieldInfo = fieldList.get(i);
String varName = "_asm_flag_" + (i / 32);
if (flag) {
print("if ((");
print(varName);
print(" & ");
print(Integer.toString(1 << i));
print(") != 0) {");
println();
incrementIndent();
}
if (fieldInfo.getMethod() != null) {
print("\tinstance.");
print(fieldInfo.getMethod().getName());
print("(");
printFieldVarName(fieldInfo);
println(");");
} else {
print("\tinstance.");
print(fieldInfo.getField().getName());
print(" = ");
printFieldVarName(fieldInfo);
println(";");
}
if (flag) {
decrementIndent();
println();
println("}");
}
}
}
示例6: _loadAndSet
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _loadAndSet(Context context, MethodVisitor mw, FieldInfo fieldInfo) {
Class<?> fieldClass = fieldInfo.getFieldClass();
Type fieldType = fieldInfo.getFieldType();
if (fieldClass == Boolean.TYPE) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(21, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (fieldClass == Byte.TYPE || fieldClass == Short.TYPE || fieldClass == Integer.TYPE || fieldClass == Character.TYPE) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(21, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (fieldClass == Long.TYPE) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(22, context.var(fieldInfo.getName() + "_asm", 2));
if (fieldInfo.getMethod() != null) {
mw.visitMethodInsn(182, ASMUtils.getType(context.getClazz()), fieldInfo.getMethod().getName(), ASMUtils.getDesc(fieldInfo.getMethod()));
if (!fieldInfo.getMethod().getReturnType().equals(Void.TYPE)) {
mw.visitInsn(87);
return;
}
return;
}
mw.visitFieldInsn(181, ASMUtils.getType(fieldInfo.getDeclaringClass()), fieldInfo.getField().getName(), ASMUtils.getDesc(fieldInfo.getFieldClass()));
} else if (fieldClass == Float.TYPE) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(23, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (fieldClass == Double.TYPE) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(24, context.var(fieldInfo.getName() + "_asm", 2));
_set(context, mw, fieldInfo);
} else if (fieldClass == String.class) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(25, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (fieldClass.isEnum()) {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(25, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (Collection.class.isAssignableFrom(fieldClass)) {
mw.visitVarInsn(25, context.var("instance"));
if (getCollectionItemClass(fieldType) == String.class) {
mw.visitVarInsn(25, context.var(fieldInfo.getName() + "_asm"));
mw.visitTypeInsn(192, ASMUtils.getType(fieldClass));
} else {
mw.visitVarInsn(25, context.var(fieldInfo.getName() + "_asm"));
}
_set(context, mw, fieldInfo);
} else {
mw.visitVarInsn(25, context.var("instance"));
mw.visitVarInsn(25, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
}
}
示例7: createStringFieldDeserializer
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
public FieldDeserializer createStringFieldDeserializer(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo) throws Exception {
Class<?> superClass;
int INVAKE_TYPE;
Class<?> fieldClass = fieldInfo.getFieldClass();
Method method = fieldInfo.getMethod();
String className = getGenFieldDeserializer(clazz, fieldInfo);
ClassWriter cw = new ClassWriter();
if (fieldClass == Integer.TYPE) {
superClass = IntegerFieldDeserializer.class;
} else if (fieldClass == Long.TYPE) {
superClass = LongFieldDeserializer.class;
} else {
superClass = StringFieldDeserializer.class;
}
if (clazz.isInterface()) {
INVAKE_TYPE = 185;
} else {
INVAKE_TYPE = 182;
}
cw.visit(49, 33, className, ASMUtils.getType(superClass), null);
MethodVisitor mw = cw.visitMethod(1, "<init>", "(Lcom/alibaba/fastjson/parser/ParserConfig;Ljava/lang/Class;Lcom/alibaba/fastjson/util/FieldInfo;)V", null, null);
mw.visitVarInsn(25, 0);
mw.visitVarInsn(25, 1);
mw.visitVarInsn(25, 2);
mw.visitVarInsn(25, 3);
mw.visitMethodInsn(183, ASMUtils.getType(superClass), "<init>", "(Lcom/alibaba/fastjson/parser/ParserConfig;Ljava/lang/Class;Lcom/alibaba/fastjson/util/FieldInfo;)V");
mw.visitInsn(177);
mw.visitMaxs(4, 6);
mw.visitEnd();
if (method != null) {
if (fieldClass == Integer.TYPE) {
mw = cw.visitMethod(1, "setValue", "(Ljava/lang/Object;I)V", null, null);
mw.visitVarInsn(25, 1);
mw.visitTypeInsn(192, ASMUtils.getType(method.getDeclaringClass()));
mw.visitVarInsn(21, 2);
mw.visitMethodInsn(INVAKE_TYPE, ASMUtils.getType(method.getDeclaringClass()), method.getName(), ASMUtils.getDesc(method));
mw.visitInsn(177);
mw.visitMaxs(3, 3);
mw.visitEnd();
} else if (fieldClass == Long.TYPE) {
mw = cw.visitMethod(1, "setValue", "(Ljava/lang/Object;J)V", null, null);
mw.visitVarInsn(25, 1);
mw.visitTypeInsn(192, ASMUtils.getType(method.getDeclaringClass()));
mw.visitVarInsn(22, 2);
mw.visitMethodInsn(INVAKE_TYPE, ASMUtils.getType(method.getDeclaringClass()), method.getName(), ASMUtils.getDesc(method));
mw.visitInsn(177);
mw.visitMaxs(3, 4);
mw.visitEnd();
} else {
mw = cw.visitMethod(1, "setValue", "(Ljava/lang/Object;Ljava/lang/Object;)V", null, null);
mw.visitVarInsn(25, 1);
mw.visitTypeInsn(192, ASMUtils.getType(method.getDeclaringClass()));
mw.visitVarInsn(25, 2);
mw.visitTypeInsn(192, ASMUtils.getType(fieldClass));
mw.visitMethodInsn(INVAKE_TYPE, ASMUtils.getType(method.getDeclaringClass()), method.getName(), ASMUtils.getDesc(method));
mw.visitInsn(177);
mw.visitMaxs(3, 3);
mw.visitEnd();
}
}
byte[] code = cw.toByteArray();
return (FieldDeserializer) this.classLoader.defineClassPublic(className, code, 0, code.length).getConstructor(new Class[]{ParserConfig.class, Class.class, FieldInfo.class}).newInstance(new Object[]{mapping, clazz, fieldInfo});
}
示例8: _loadAndSet
import com.alibaba.fastjson.util.FieldInfo; //导入方法依赖的package包/类
private void _loadAndSet(Context context, MethodVisitor mw, FieldInfo fieldInfo) {
Class<?> fieldClass = fieldInfo.getFieldClass();
Type fieldType = fieldInfo.getFieldType();
if (fieldClass == boolean.class) {
mw.visitVarInsn(ALOAD, context.var("instance"));
mw.visitVarInsn(ILOAD, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (fieldClass == byte.class //
|| fieldClass == short.class //
|| fieldClass == int.class //
|| fieldClass == char.class) {
mw.visitVarInsn(ALOAD, context.var("instance"));
mw.visitVarInsn(ILOAD, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (fieldClass == long.class) {
mw.visitVarInsn(ALOAD, context.var("instance"));
mw.visitVarInsn(LLOAD, context.var(fieldInfo.getName() + "_asm", 2));
if (fieldInfo.getMethod() != null) {
mw.visitMethodInsn(INVOKEVIRTUAL, getType(context.getClazz()), fieldInfo.getMethod().getName(),
getDesc(fieldInfo.getMethod()));
if (!fieldInfo.getMethod().getReturnType().equals(Void.TYPE)) {
mw.visitInsn(POP);
}
} else {
mw.visitFieldInsn(PUTFIELD, getType(fieldInfo.getDeclaringClass()), fieldInfo.getField().getName(),
getDesc(fieldInfo.getFieldClass()));
}
} else if (fieldClass == float.class) {
mw.visitVarInsn(ALOAD, context.var("instance"));
mw.visitVarInsn(FLOAD, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (fieldClass == double.class) {
mw.visitVarInsn(ALOAD, context.var("instance"));
mw.visitVarInsn(DLOAD, context.var(fieldInfo.getName() + "_asm", 2));
_set(context, mw, fieldInfo);
} else if (fieldClass == String.class) {
mw.visitVarInsn(ALOAD, context.var("instance"));
mw.visitVarInsn(ALOAD, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (fieldClass.isEnum()) {
mw.visitVarInsn(ALOAD, context.var("instance"));
mw.visitVarInsn(ALOAD, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
} else if (Collection.class.isAssignableFrom(fieldClass)) {
mw.visitVarInsn(ALOAD, context.var("instance"));
Type itemType = TypeUtils.getCollectionItemClass(fieldType);
if (itemType == String.class) {
mw.visitVarInsn(ALOAD, context.var(fieldInfo.getName() + "_asm"));
mw.visitTypeInsn(CHECKCAST, getType(fieldClass)); // cast
} else {
mw.visitVarInsn(ALOAD, context.var(fieldInfo.getName() + "_asm"));
}
_set(context, mw, fieldInfo);
} else {
// mw.visitFieldInsn(GETSTATIC, getType(System.class), "out", "Ljava/io/PrintStream;");
// mw.visitIntInsn(ILOAD, context.var(fieldInfo.getName() + "_asm_flag"));
// mw.visitMethodInsn(INVOKEVIRTUAL, getType(java.io.PrintStream.class), "println", "(I)V");
// _isFlag(mw, context, i, notSet_);
mw.visitVarInsn(ALOAD, context.var("instance"));
mw.visitVarInsn(ALOAD, context.var(fieldInfo.getName() + "_asm"));
_set(context, mw, fieldInfo);
}
}