Java Code Examples for org.springframework.asm.Type#getType()
The following examples show how to use
org.springframework.asm.Type#getType() .
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: ReflectUtils.java From spring-analysis-note with MIT License | 6 votes |
public static ClassInfo getClassInfo(final Class clazz) { final Type type = Type.getType(clazz); final Type sc = (clazz.getSuperclass() == null) ? null : Type.getType(clazz.getSuperclass()); return new ClassInfo() { public Type getType() { return type; } public Type getSuperType() { return sc; } public Type[] getInterfaces() { return TypeUtils.getTypes(clazz.getInterfaces()); } public int getModifiers() { return clazz.getModifiers(); } }; }
Example 2
Source File: ReflectUtils.java From java-technology-stack with MIT License | 6 votes |
public static ClassInfo getClassInfo(final Class clazz) { final Type type = Type.getType(clazz); final Type sc = (clazz.getSuperclass() == null) ? null : Type.getType(clazz.getSuperclass()); return new ClassInfo() { public Type getType() { return type; } public Type getSuperType() { return sc; } public Type[] getInterfaces() { return TypeUtils.getTypes(clazz.getInterfaces()); } public int getModifiers() { return clazz.getModifiers(); } }; }
Example 3
Source File: Enhancer.java From spring-analysis-note with MIT License | 5 votes |
private Type getThisType(CodeEmitter e) { if (currentData == null) { return e.getClassEmitter().getClassType(); } else { return Type.getType(currentData.generatedClass); } }
Example 4
Source File: Enhancer.java From java-technology-stack with MIT License | 5 votes |
private Type getThisType(CodeEmitter e) { if (currentData == null) { return e.getClassEmitter().getClassType(); } else { return Type.getType(currentData.generatedClass); } }
Example 5
Source File: MicaBeanCopier.java From mica with GNU Lesser General Public License v3.0 | 4 votes |
/** * 处理 map 的 copy * @param ce ClassEmitter * @param e CodeEmitter * @param sourceType sourceType * @param targetType targetType */ public void generateClassFormMap(ClassEmitter ce, CodeEmitter e, Type sourceType, Type targetType) { // 2018.12.27 by L.cm 支持链式 bean PropertyDescriptor[] setters = ReflectUtil.getBeanSetters(target); // 入口变量 Local targetLocal = e.make_local(); Local sourceLocal = e.make_local(); e.load_arg(1); e.checkcast(targetType); e.store_local(targetLocal); e.load_arg(0); e.checkcast(sourceType); e.store_local(sourceLocal); Type mapBox = Type.getType(Object.class); for (PropertyDescriptor setter : setters) { String propName = setter.getName(); // set 上有忽略的 注解 CopyProperty targetIgnoreCopy = ReflectUtil.getAnnotation(target, propName, CopyProperty.class); if (targetIgnoreCopy != null) { if (targetIgnoreCopy.ignore()) { continue; } // 注解上的别名 String aliasTargetPropName = targetIgnoreCopy.value(); if (StringUtil.isNotBlank(aliasTargetPropName)) { propName = aliasTargetPropName; } } Method writeMethod = setter.getWriteMethod(); MethodInfo write = ReflectUtils.getMethodInfo(writeMethod); Type setterType = write.getSignature().getArgumentTypes()[0]; e.load_local(targetLocal); e.load_local(sourceLocal); e.push(propName); // 执行 map get e.invoke_interface(BEAN_MAP, BEAN_MAP_GET); // box 装箱,避免 array[] 数组问题 e.box(mapBox); // 生成变量 Local var = e.make_local(); e.store_local(var); e.load_local(var); // 先判断 不为null,然后做类型判断 Label l0 = e.make_label(); e.ifnull(l0); EmitUtils.load_class(e, setterType); e.load_local(var); // ClassUtils.isAssignableValue(Integer.class, id) e.invoke_static(CLASS_UTILS, IS_ASSIGNABLE_VALUE, false); Label l1 = new Label(); // 返回值,判断 链式 bean Class<?> returnType = writeMethod.getReturnType(); if (useConverter) { e.if_jump(Opcodes.IFEQ, l1); e.load_local(targetLocal); e.load_local(var); e.unbox_or_zero(setterType); e.invoke(write); if (!returnType.equals(Void.TYPE)) { e.pop(); } e.goTo(l0); e.visitLabel(l1); e.load_local(targetLocal); e.load_arg(2); e.load_local(var); EmitUtils.load_class(e, setterType); e.push(propName); e.invoke_interface(CONVERTER, CONVERT); } else { e.if_jump(Opcodes.IFEQ, l0); e.load_local(targetLocal); e.load_local(var); } e.unbox_or_zero(setterType); e.invoke(write); // 返回值,判断 链式 bean if (!returnType.equals(Void.TYPE)) { e.pop(); } e.visitLabel(l0); } e.return_value(); e.end_method(); ce.end_class(); }