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()); }
String s1Type = AsmUtils.toWrapperType(s1); String s2Type = AsmUtils.toWrapperType(s2); String classType = AsmUtils.toAsmType(className); String instantiatorType = AsmUtils.toAsmType(BI_INSTANTIATOR_CLASS);
String s1Type = AsmUtils.toWrapperType(s1); String s2Type = AsmUtils.toWrapperType(s2); String classType = AsmUtils.toAsmType(className); String instantiatorType = AsmUtils.toAsmType(BI_INSTANTIATOR_CLASS);
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 <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()); }