-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly handle missing classes in metadata + precalculated requirements #10936
Conversation
Newly generated code: static {
$ANNOTATION_METADATA = new AnnotationMetadataHierarchy(new AnnotationMetadata[]{new DefaultAnnotationMetadata(Map.of("io.micronaut.context.annotation.Factory", Map.of(), "jakarta.inject.Singleton", Map.of()), Map.of("io.micronaut.context.annotation.DefaultScope", Map.of("value", $micronaut_load_class_value_0())), Map.of("io.micronaut.context.annotation.DefaultScope", Map.of("value", $micronaut_load_class_value_0())), Map.of("io.micronaut.context.annotation.Factory", Map.of(), "jakarta.inject.Singleton", Map.of()), Map.of("io.micronaut.context.annotation.DefaultScope", List.of("io.micronaut.context.annotation.Factory")), false, false), new DefaultAnnotationMetadata(Map.of("io.micronaut.context.annotation.Bean", Map.of(), "io.micronaut.context.annotation.Requirements", Map.of("value", new AnnotationValue[]{new AnnotationValue("io.micronaut.context.annotation.Requires", Map.of("beans", new AnnotationClassValue[]{$micronaut_load_class_value_1()}, "missingBeans", new AnnotationClassValue[]{$micronaut_load_class_value_2()}), AnnotationMetadataSupport.ANNOTATION_DEFAULT_VALUES_PROVIDER)})), Map.of(), Map.of(), Map.of("io.micronaut.context.annotation.Bean", Map.of(), "io.micronaut.context.annotation.Requirements", Map.of("value", new AnnotationValue[]{new AnnotationValue("io.micronaut.context.annotation.Requires", Map.of("beans", new AnnotationClassValue[]{$micronaut_load_class_value_1()}, "missingBeans", new AnnotationClassValue[]{$micronaut_load_class_value_2()}), AnnotationMetadataSupport.ANNOTATION_DEFAULT_VALUES_PROVIDER)})), Map.of(), false, false)});
try {
$CONSTRUCTOR = new AbstractInitializableBeanDefinition.MethodReference(AFactory.class, "a", new Argument[]{Argument.of(X.class, "x")}, new DefaultAnnotationMetadata(Map.of("io.micronaut.context.annotation.Bean", Map.of(), "io.micronaut.context.annotation.Factory", Map.of(), "io.micronaut.context.annotation.Requirements", Map.of("value", new AnnotationValue[]{new AnnotationValue("io.micronaut.context.annotation.Requires", Map.of("beans", new AnnotationClassValue[]{$micronaut_load_class_value_1()}, "missingBeans", new AnnotationClassValue[]{$micronaut_load_class_value_2()}), AnnotationMetadataSupport.ANNOTATION_DEFAULT_VALUES_PROVIDER)}), "jakarta.inject.Singleton", Map.of()), Map.of("io.micronaut.context.annotation.DefaultScope", Map.of("value", $micronaut_load_class_value_0())), Map.of("io.micronaut.context.annotation.DefaultScope", Map.of("value", $micronaut_load_class_value_0())), Map.of("io.micronaut.context.annotation.Bean", Map.of(), "io.micronaut.context.annotation.Factory", Map.of(), "io.micronaut.context.annotation.Requirements", Map.of("value", new AnnotationValue[]{new AnnotationValue("io.micronaut.context.annotation.Requires", Map.of("beans", new AnnotationClassValue[]{$micronaut_load_class_value_1()}, "missingBeans", new AnnotationClassValue[]{$micronaut_load_class_value_2()}), AnnotationMetadataSupport.ANNOTATION_DEFAULT_VALUES_PROVIDER)}), "jakarta.inject.Singleton", Map.of()), Map.of("io.micronaut.context.annotation.DefaultScope", List.of("io.micronaut.context.annotation.Factory")), false, false));
} catch (Throwable var0) {
$FAILURE = var0;
$CONSTRUCTOR = null;
}
$INFO = new AbstractInitializableBeanDefinition.PrecalculatedInfo(Optional.empty(), false, false, false, false, false, false, false, false);
$PRE_CONDITIONS = new Condition[]{new MatchesPresenceOfClassesCondition(new AnnotationClassValue[]{$micronaut_load_class_value_1()})};
$POST_CONDITIONS = new Condition[]{new MatchesPresenceOfBeansCondition(new AnnotationClassValue[]{$micronaut_load_class_value_1()}), new MatchesAbsenseOfBeansCondition(new AnnotationClassValue[]{$micronaut_load_class_value_2()})};
} |
inject/src/main/java/io/micronaut/context/AbstractInitializableBeanDefinitionAndReference.java
Outdated
Show resolved
Hide resolved
inject/src/main/java/io/micronaut/context/AbstractInitializableBeanDefinitionAndReference.java
Show resolved
Hide resolved
* @since 4.6 | ||
*/ | ||
@NonNull | ||
public static <E extends Enum<E>> EnumSet<E> enumSet(@NonNull E... enums) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add nullability annotations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of nullability annotations?
inject/src/main/java/io/micronaut/context/DefaultBeanContext.java
Outdated
Show resolved
Hide resolved
AbstractInitializableBeanDefinition.PrecalculatedInfo.class, // precalculated info | ||
Condition[].class, // pre conditions | ||
Condition[].class, // post conditions | ||
Throwable.class // failed initialization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you change this slightly to try lookup this constructor otherwise if not there fallback to the other constructor. Otherwise we will hit binary compatibility issues for all the modules again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not break anything, that's the new super constructor. We have some modules that have been compiled with previous version and tests are passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes but if there is an old version of micronaut-inject
then the lookup will fail which means we will have to release new versions of every minor release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is it possible to have an older version of micronaut-inject? Inject and core-processor should always come with the same version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there seem to be some test failures |
@dstepanov pls address the sonar stuff before merging |
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Fixes #10931