Skip to content

Commit

Permalink
Fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Apr 19, 2018
1 parent 7dd7383 commit bf0cea0
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 36 deletions.
8 changes: 4 additions & 4 deletions aop/src/main/java/io/micronaut/aop/writer/AopProxyWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -801,14 +801,14 @@ public void accept(ClassWriterOutputVisitor visitor) throws IOException {
@Override
public void visitSetterInjectionPoint(
Object declaringType,
io.micronaut.inject.annotation.AnnotationValue qualifierType,
AnnotationMetadata fieldMetadata,
boolean requiresReflection,
Object fieldType,
String fieldName,
String setterName,
Map<String, Object> genericTypes) {
deferredInjectionPoints.add(() -> proxyBeanDefinitionWriter.visitSetterInjectionPoint(
declaringType, qualifierType, requiresReflection, fieldType, fieldName, setterName, genericTypes
declaringType, fieldMetadata, requiresReflection, fieldType, fieldName, setterName, genericTypes
));
}

Expand All @@ -825,15 +825,15 @@ public void visitSuperBeanDefinitionFactory(String beanName) {
@Override
public void visitSetterValue(
Object declaringType,
Object qualifierType,
AnnotationMetadata annotationMetadata,
boolean requiresReflection,
Object fieldType,
String fieldName,
String setterName,
Map<String, Object> genericTypes,
boolean isOptional) {
deferredInjectionPoints.add(() -> proxyBeanDefinitionWriter.visitSetterValue(
declaringType, qualifierType, requiresReflection, fieldType, fieldName, setterName, genericTypes, isOptional
declaringType, annotationMetadata, requiresReflection, fieldType, fieldName, setterName, genericTypes, isOptional
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
@Override
void accept(ClassNode classNode, MethodNode methodNode) {
Map<String, Object> targetMethodParamsToType = [:]
Map<String, Object> targetMethodQualifierTypes = [:]
Map<String, AnnotationMetadata> targetAnnotationMetadata = [:]
Map<String, Map<String, Object>> targetMethodGenericTypeMap = [:]

Map<String, ClassNode> boundTypes = AstGenericUtils.createGenericsSpec(classNode)
Expand All @@ -372,7 +372,7 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
populateParameterData(
methodNode.parameters,
targetMethodParamsToType,
targetMethodQualifierTypes,
targetAnnotationMetadata,
targetMethodGenericTypeMap)


Expand All @@ -392,7 +392,7 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
resolvedGenericTypes,
methodNode.name,
targetMethodParamsToType,
targetMethodQualifierTypes,
targetAnnotationMetadata,
targetMethodGenericTypeMap,
annotationMetadata
)
Expand Down Expand Up @@ -471,7 +471,7 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
@Override
void accept(ClassNode classNode, MethodNode targetBeanMethodNode) {
Map<String, Object> targetMethodParamsToType = [:]
Map<String, Object> targetMethodQualifierTypes = [:]
Map<String, AnnotationMetadata> targetAnnotationMetadata = [:]
Map<String, Map<String, Object>> targetMethodGenericTypeMap = [:]
Map<String, ClassNode> boundTypes = AstGenericUtils.createGenericsSpec(classNode)
Object resolvedReturnType = AstGenericUtils.resolveTypeReference(targetBeanMethodNode.returnType, boundTypes)
Expand All @@ -484,7 +484,7 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
populateParameterData(
targetBeanMethodNode.parameters,
targetMethodParamsToType,
targetMethodQualifierTypes,
targetAnnotationMetadata,
targetMethodGenericTypeMap)
AnnotationMetadata annotationMetadata
if (AstAnnotationUtils.isAnnotated(methodNode)) {
Expand All @@ -503,7 +503,7 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
resolvedGenericTypes,
targetBeanMethodNode.name,
targetMethodParamsToType,
targetMethodQualifierTypes,
targetAnnotationMetadata,
targetMethodGenericTypeMap,
annotationMetadata
)
Expand All @@ -515,7 +515,7 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
resolvedGenericTypes,
targetBeanMethodNode.name,
targetMethodParamsToType,
targetMethodQualifierTypes,
targetAnnotationMetadata,
targetMethodGenericTypeMap,
new AnnotationMetadataReference(writer.getClassName(), annotationMetadata)
)
Expand Down Expand Up @@ -833,8 +833,6 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
boolean isValue = !isInject && fieldNode != null && (fieldAnnotationMetadata.hasStereotype(Value) || isConfigurationProperties)
if (!propertyNode.isStatic() && (isInject || isValue)) {
defineBeanDefinition(concreteClass)
Object qualifier = resolveQualifier(fieldNode)

ClassNode fieldType = fieldNode.type

GenericsType[] genericsTypes = fieldType.genericsTypes
Expand All @@ -855,7 +853,7 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
if (isInject) {
getBeanWriter().visitSetterInjectionPoint(
AstGenericUtils.resolveTypeReference(declaringClass),
qualifier,
fieldAnnotationMetadata,
false,
AstGenericUtils.resolveTypeReference(fieldType),
fieldNode.name,
Expand All @@ -878,7 +876,7 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
} else {
getBeanWriter().visitSetterValue(
AstGenericUtils.resolveTypeReference(declaringClass),
qualifier,
fieldAnnotationMetadata,
false,
AstGenericUtils.resolveTypeReference(fieldType),
fieldNode.name,
Expand All @@ -891,14 +889,18 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
} else if (isAopProxyType && !propertyNode.isStatic()) {
AopProxyWriter aopWriter = (AopProxyWriter) aopProxyWriter
if (aopProxyWriter != null) {
Map<String, Map<String, Object>> resolvedGenericTypes = [(propertyNode.name): AstGenericUtils.extractPlaceholders(propertyNode.type)]
Map<String, Object> resolvedArguments = [(propertyNode.name): AstGenericUtils.resolveTypeReference(propertyNode.type)]
Object qualifier = resolveQualifier(propertyNode.field)
Map<String, Object> resolvedQualifiers
if (qualifier != null) {
resolvedQualifiers = [(propertyNode.name): qualifier]
Map<String, Map<String, Object>> resolvedGenericTypes =
[(propertyNode.name): AstGenericUtils.extractPlaceholders(propertyNode.type)]
Map<String, Object> resolvedArguments =
[(propertyNode.name): AstGenericUtils.resolveTypeReference(propertyNode.type)]

AnnotationMetadata fieldMetadata = AstAnnotationUtils.getAnnotationMetadata(propertyNode.field)

Map<String, AnnotationMetadata> resolvedAnnotationMetadata
if (fieldMetadata != null) {
resolvedAnnotationMetadata = [(propertyNode.name): fieldMetadata]
} else {
resolvedQualifiers = Collections.emptyMap()
resolvedAnnotationMetadata = Collections.emptyMap()
}
aopWriter.visitAroundMethod(
propertyNode.getDeclaringClass().name,
Expand All @@ -907,7 +909,7 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
Collections.emptyMap(),
getSetterName(propertyNode.name),
resolvedArguments,
resolvedQualifiers,
resolvedAnnotationMetadata,
resolvedGenericTypes,
fieldAnnotationMetadata
)
Expand Down Expand Up @@ -957,7 +959,7 @@ class InjectTransform implements ASTTransformation, CompilationUnitAware {
ConstructorNode constructorNode = findConcreteConstructor(constructors)
if (constructorNode != null) {
Map<String, Object> paramsToType = [:]
Map<String, Object> qualifierTypes = [:]
Map<String, AnnotationMetadata> qualifierTypes = [:]
Map<String, Map<String, Object>> genericTypeMap = [:]
Parameter[] parameters = constructorNode.parameters
populateParameterData(parameters, paramsToType, qualifierTypes, genericTypeMap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public class AbstractBeanDefinition<T> extends AbstractBeanContextConditional im
private Map<Class, String> valuePrefixes;

/**
* Constructs a bean definition that is produced from a method call on another type
* Constructs a bean definition that is produced from a method call on another type ( factory bean )
*
* @param method The method to call
* @param arguments The arguments
Expand All @@ -151,6 +151,12 @@ protected AbstractBeanDefinition(Method method,
this.addRequiredComponents(arguments);
}

/**
* Constructs a bean for the given type
* @param type The type
* @param constructor
* @param arguments The constructor arguments used to build the bean
*/
@Internal
protected AbstractBeanDefinition(Class<T> type,
Constructor<T> constructor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ void visitProxiedBeanDefinitionConstructor(
* Visits an injection point for a field and setter pairing.
*
* @param declaringType The declaring type
* @param qualifierType The qualifier type
* @param fieldMetadata The qualifier type
* @param requiresReflection Whether the setter requires reflection
* @param fieldType The field type
* @param fieldName The field name
* @param setterName The setter name
* @param genericTypes The generic types
*/
void visitSetterInjectionPoint(Object declaringType,
AnnotationValue qualifierType,
AnnotationMetadata fieldMetadata,
boolean requiresReflection,
Object fieldType,
String fieldName,
Expand All @@ -178,7 +178,7 @@ void visitSetterInjectionPoint(Object declaringType,
* Visits an injection point for a field and setter pairing.
*
* @param declaringType The declaring type
* @param qualifierType The qualifier type
* @param annotationMetadata The annotation metadata
* @param requiresReflection Whether the setter requires reflection
* @param fieldType The field type
* @param fieldName The field name
Expand All @@ -187,7 +187,7 @@ void visitSetterInjectionPoint(Object declaringType,
* @param isOptional Whether the setter is optional
*/
void visitSetterValue(Object declaringType,
Object qualifierType,
AnnotationMetadata annotationMetadata,
boolean requiresReflection,
Object fieldType,
String fieldName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,15 +612,15 @@ public void accept(ClassWriterOutputVisitor visitor) throws IOException {

@Override
public void visitSetterInjectionPoint(Object declaringType,
AnnotationValue qualifierType,
AnnotationMetadata fieldMetadata,
boolean requiresReflection,
Object fieldType,
String fieldName,
String setterName,
Map<String, Object> genericTypes) {
Type declaringTypeRef = getTypeReference(declaringType);

addInjectionPointForSetterInternal(qualifierType, requiresReflection, fieldType, fieldName, setterName, genericTypes, declaringTypeRef);
addInjectionPointForSetterInternal(fieldMetadata, requiresReflection, fieldType, fieldName, setterName, genericTypes, declaringTypeRef);

if (!requiresReflection) {
resolveBeanOrValueForSetter(declaringTypeRef, setterName, fieldType, GET_BEAN_FOR_METHOD_ARGUMENT, false);
Expand All @@ -631,7 +631,7 @@ public void visitSetterInjectionPoint(Object declaringType,

@Override
public void visitSetterValue(Object declaringType,
Object qualifierType,
AnnotationMetadata annotationMetadata,
boolean requiresReflection,
Object fieldType,
String fieldName,
Expand All @@ -640,7 +640,7 @@ public void visitSetterValue(Object declaringType,
boolean isOptional) {
Type declaringTypeRef = getTypeReference(declaringType);

addInjectionPointForSetterInternal(qualifierType, requiresReflection, fieldType, fieldName, setterName, genericTypes, declaringTypeRef);
addInjectionPointForSetterInternal(annotationMetadata, requiresReflection, fieldType, fieldName, setterName, genericTypes, declaringTypeRef);

if (!requiresReflection) {
resolveBeanOrValueForSetter(declaringTypeRef, setterName, fieldType, GET_VALUE_FOR_METHOD_ARGUMENT, isOptional);
Expand Down Expand Up @@ -1298,7 +1298,7 @@ private int pushGetMethodFromTypeCallLocalVariable(GeneratorAdapter methodVisito
}

private void addInjectionPointForSetterInternal(
Object qualifierType,
AnnotationMetadata fieldAnnotationMetadata,
boolean requiresReflection,
Object fieldType,
String fieldName,
Expand All @@ -1324,8 +1324,15 @@ private void addInjectionPointForSetterInternal(
// 2nd argument: The argument name
generatorAdapter.push(fieldName);
// 3rd argument: The qualifier type
if (qualifierType != null) {
generatorAdapter.push(getTypeReference(qualifierType));
if (fieldAnnotationMetadata != null) {
// TODO: replace write metadata
Optional<String> qualifier = fieldAnnotationMetadata.getAnnotationNameByStereotype(Qualifier.class);
if(qualifier.isPresent()) {
generatorAdapter.push(getTypeReference(qualifier.get()));
}
else {
generatorAdapter.visitInsn(ACONST_NULL);
}
} else {
generatorAdapter.visitInsn(ACONST_NULL);
}
Expand Down

0 comments on commit bf0cea0

Please sign in to comment.