return AsmUtils.writeClassToFile(className, cw.toByteArray());
cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray());
public static byte[] createObjectSetter(final String className, final Field field) throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); MethodVisitor mv; Class<?> target = field.getDeclaringClass(); Class<?> property = field.getType(); String targetType = toType(target); String propertyType = toType(property); String classType = toType(className); cw.visit( V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, classType, "Ljava/lang/Object;L" + SETTER_TYPE + "<L" + targetType + ";" + AsmUtils.toTargetTypeDeclaration(propertyType) + ">;", "java/lang/Object", new String[] {SETTER_TYPE}); { mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); mv.visitInsn(RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); } appendSet(field, cw, target, targetType, propertyType, classType); appendToString(cw); cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray()); }
public static byte[] createObjectSetter(final String className, final Method method) throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); MethodVisitor mv; Class<?> target = method.getDeclaringClass(); Class<?> property = method.getParameterTypes()[0]; String targetType = toType(target); String propertyType = toType(property); String classType = toType(className); cw.visit( V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, classType, "Ljava/lang/Object;L" + SETTER_TYPE + "<L" + targetType + ";" + AsmUtils.toTargetTypeDeclaration(propertyType) + ">;", "java/lang/Object", new String[] {SETTER_TYPE}); { mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); mv.visitInsn(RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); } appendSet(method, cw, target, targetType, propertyType, classType); appendToString(cw); cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray()); }
public static byte[] createObjectSetter(final String className, final Field field) throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); MethodVisitor mv; Class<?> target = field.getDeclaringClass(); Class<?> property = field.getType(); String targetType = toType(target); String propertyType = toType(property); String classType = toType(className); cw.visit( V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, classType, "Ljava/lang/Object;L" + SETTER_TYPE + "<L" + targetType + ";" + AsmUtils.toTargetTypeDeclaration(propertyType) + ">;", "java/lang/Object", new String[] {SETTER_TYPE}); { mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); mv.visitInsn(RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); } appendSet(field, cw, target, targetType, propertyType, classType); appendToString(cw); cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray()); }
public static byte[] createObjectSetter(final String className, final Method method) throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); MethodVisitor mv; Class<?> target = method.getDeclaringClass(); Class<?> property = method.getParameterTypes()[0]; String targetType = toType(target); String propertyType = toType(property); String classType = toType(className); cw.visit( V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, classType, "Ljava/lang/Object;L" + SETTER_TYPE + "<L" + targetType + ";" + AsmUtils.toTargetTypeDeclaration(propertyType) + ">;", "java/lang/Object", new String[] {SETTER_TYPE}); { mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); mv.visitInsn(RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); } appendSet(method, cw, target, targetType, propertyType, classType); appendToString(cw); cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray()); }
return AsmUtils.writeClassToFile(className, cw.toByteArray());
return AsmUtils.writeClassToFile(className, cw.toByteArray());
return AsmUtils.writeClassToFile(className, cw.toByteArray());
return AsmUtils.writeClassToFile(className, cw.toByteArray());
public static <S> byte[] createInstantiator(final String className, final Class<?> sourceClass, final ExecutableInstantiatorDefinition instantiatorDefinition, final Map<Parameter, Getter<? super S, ?>> injections) throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); Class<?> targetClass= TypeHelper.toClass(BiInstantiatorBuilder.getTargetType(instantiatorDefinition)); String targetType = AsmUtils.toAsmType(targetClass); String sourceType = AsmUtils.toWrapperType(sourceClass); String classType = AsmUtils.toAsmType(className); String instantiatorType = AsmUtils.toAsmType(Instantiator.class); cw.visit(V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, classType, "Ljava/lang/Object;L" + instantiatorType + "<L" + targetType + ";>;", "java/lang/Object", new String[] { instantiatorType }); Parameter[] parameters = instantiatorDefinition.getParameters(); appendGetters(injections, cw); appendInit(injections, cw, sourceType, classType); appendNewInstanceBuilderOnMethod(sourceClass, instantiatorDefinition, injections, cw, targetType, sourceType, classType, parameters); appendBridgeMethod(cw, targetType, sourceType, classType); appendToString(injections, cw, parameters); cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray()); }
public static <S> byte[] createInstantiator(final String className, final Class<?> sourceClass, final ExecutableInstantiatorDefinition instantiatorDefinition, final Map<Parameter, Getter<? super S, ?>> injections) throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); Class<?> targetClass= TypeHelper.toClass(BiInstantiatorBuilder.getTargetType(instantiatorDefinition)); String targetType = AsmUtils.toAsmType(targetClass); String sourceType = AsmUtils.toWrapperType(sourceClass); String classType = AsmUtils.toAsmType(className); String instantiatorType = AsmUtils.toAsmType(Instantiator.class); cw.visit(V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, classType, "Ljava/lang/Object;L" + instantiatorType + "<L" + targetType + ";>;", "java/lang/Object", new String[] { instantiatorType }); Parameter[] parameters = instantiatorDefinition.getParameters(); appendGetters(injections, cw); appendInit(injections, cw, sourceType, classType); appendNewInstanceBuilderOnMethod(sourceClass, instantiatorDefinition, injections, cw, targetType, sourceType, classType, parameters); appendBridgeMethod(cw, targetType, sourceType, classType); appendToString(injections, cw, parameters); cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray()); }
public static <S1, S2> byte[] createInstantiator(final String className, final Class<?> s1, final Class<?> s2, final ExecutableInstantiatorDefinition instantiatorDefinition, final Map<Parameter, BiFunction<? super S1, ? super S2, ?>> injectionsMap) throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); Class<?> targetClass= TypeHelper.toClass(getTargetType(instantiatorDefinition)); String targetType = AsmUtils.toAsmType(targetClass); String s1Type = AsmUtils.toWrapperType(s1); String s2Type = AsmUtils.toWrapperType(s2); String classType = AsmUtils.toAsmType(className); String instantiatorType = AsmUtils.toAsmType(BI_INSTANTIATOR_CLASS); List<InjectionPoint> injections = toInjections(injectionsMap); cw.visit(V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, classType, "Ljava/lang/Object;L" + instantiatorType + "<L" + targetType + ";>;", "java/lang/Object", new String[] { instantiatorType }); Parameter[] parameters = instantiatorDefinition.getParameters(); appendFunctionsField(injections, cw); appendInit(injections, cw, s1Type, s2Type, classType); appendNewInstance(s1, s2, instantiatorDefinition, injections, cw, targetType, s1Type, s2Type, classType, parameters); appendBridgeMethod(cw, targetType, s1Type, s2Type, classType); appendToString(injections, cw, parameters); cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray()); }
public static <S1, S2> byte[] createInstantiator(final String className, final Class<?> s1, final Class<?> s2, final ExecutableInstantiatorDefinition instantiatorDefinition, final Map<Parameter, BiFunction<? super S1, ? super S2, ?>> injectionsMap) throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); Class<?> targetClass= TypeHelper.toClass(getTargetType(instantiatorDefinition)); String targetType = AsmUtils.toAsmType(targetClass); String s1Type = AsmUtils.toWrapperType(s1); String s2Type = AsmUtils.toWrapperType(s2); String classType = AsmUtils.toAsmType(className); String instantiatorType = AsmUtils.toAsmType(BI_INSTANTIATOR_CLASS); List<InjectionPoint> injections = toInjections(injectionsMap); cw.visit(V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, classType, "Ljava/lang/Object;L" + instantiatorType + "<L" + targetType + ";>;", "java/lang/Object", new String[] { instantiatorType }); Parameter[] parameters = instantiatorDefinition.getParameters(); appendFunctionsField(injections, cw); appendInit(injections, cw, s1Type, s2Type, classType); appendNewInstance(s1, s2, instantiatorDefinition, injections, cw, targetType, s1Type, s2Type, classType, parameters); appendBridgeMethod(cw, targetType, s1Type, s2Type, classType); appendToString(injections, cw, parameters); cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray()); }
public static <S> byte[] createInstantiator(final String className, final Class<?> sourceClass, final BuilderInstantiatorDefinition instantiatorDefinition, final Map<Parameter, Getter<? super S, ?>> injections, boolean ignoreNullValues) throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); Class<?> targetClass= TypeHelper.toClass(BiInstantiatorBuilder.getTargetType(instantiatorDefinition)); String targetType = AsmUtils.toAsmType(targetClass); String sourceType = AsmUtils.toWrapperType(sourceClass); String classType = AsmUtils.toAsmType(className); String instantiatorType = AsmUtils.toAsmType(Instantiator.class); cw.visit(V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, classType, "Ljava/lang/Object;L" + instantiatorType + "<L" + targetType + ";>;", "java/lang/Object", new String[] { instantiatorType }); { FieldVisitor fv = cw.visitField( ACC_FINAL, "builderInstantiator", "L" + AsmUtils.toAsmType(Instantiator.class) + ";", "L" + AsmUtils.toAsmType(Instantiator.class) + "<Ljava/lang/Void;L" + AsmUtils.toAsmType(BiInstantiatorBuilder.getTargetType(instantiatorDefinition.getBuilderInstantiator())) + ";>;", null); fv.visitEnd(); } appendGetters(injections, cw); appendInitBuilder(injections, cw, sourceType, classType, instantiatorDefinition); appendNewInstanceBuilderOnBuilder(sourceClass, instantiatorDefinition, injections, cw, targetType, sourceType, classType, instantiatorDefinition.getSetters(), ignoreNullValues); appendBridgeMethod(cw, targetType, sourceType, classType); appendToString(injections, cw, instantiatorDefinition.getParameters()); cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray()); }
public static <S> byte[] createInstantiator(final String className, final Class<?> sourceClass, final BuilderInstantiatorDefinition instantiatorDefinition, final Map<Parameter, Getter<? super S, ?>> injections, boolean ignoreNullValues) throws Exception { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); Class<?> targetClass= TypeHelper.toClass(BiInstantiatorBuilder.getTargetType(instantiatorDefinition)); String targetType = AsmUtils.toAsmType(targetClass); String sourceType = AsmUtils.toWrapperType(sourceClass); String classType = AsmUtils.toAsmType(className); String instantiatorType = AsmUtils.toAsmType(Instantiator.class); cw.visit(V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, classType, "Ljava/lang/Object;L" + instantiatorType + "<L" + targetType + ";>;", "java/lang/Object", new String[] { instantiatorType }); { FieldVisitor fv = cw.visitField( ACC_FINAL, "builderInstantiator", "L" + AsmUtils.toAsmType(Instantiator.class) + ";", "L" + AsmUtils.toAsmType(Instantiator.class) + "<Ljava/lang/Void;L" + AsmUtils.toAsmType(BiInstantiatorBuilder.getTargetType(instantiatorDefinition.getBuilderInstantiator())) + ";>;", null); fv.visitEnd(); } appendGetters(injections, cw); appendInitBuilder(injections, cw, sourceType, classType, instantiatorDefinition); appendNewInstanceBuilderOnBuilder(sourceClass, instantiatorDefinition, injections, cw, targetType, sourceType, classType, instantiatorDefinition.getSetters(), ignoreNullValues); appendBridgeMethod(cw, targetType, sourceType, classType); appendToString(injections, cw, instantiatorDefinition.getParameters()); cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray()); }
cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray());
cw.visitEnd(); return AsmUtils.writeClassToFile(className, cw.toByteArray());
return AsmUtils.writeClassToFile(className, cw.toByteArray());
return AsmUtils.writeClassToFile(className, cw.toByteArray());