Skip to content
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

@Import doesn't create bean definition for inner classes in package #8566

Closed
auke- opened this issue Jan 3, 2023 · 0 comments
Closed

@Import doesn't create bean definition for inner classes in package #8566

auke- opened this issue Jan 3, 2023 · 0 comments
Milestone

Comments

@auke-
Copy link
Contributor

auke- commented Jan 3, 2023

Expected Behavior

When using @Import(packages = "my.package") one would expect that a bean definition is created for all classes which match either the default annotations or a specified annotation.

e.g.

package to.be.imported;

import jakarta.inject.Singleton;

public class Outer {
  @Singleton
  public static class Inner {
  }
}

package using.imported.bean;

import io.micronaut.context.annotation.Bean;
import io.micronaut.context.annotation.Factory;
import io.micronaut.context.annotation.Import;
import jakarta.inject.Singleton;

@Import(packages = "to.be.imported", annotated = "jakarta.inject.Singleton")
@Factory
public class Factory {

  @Bean @Singleton
  Object createUsingInner(Inner importedBean) {
   ...
  }
}

Actual Behaviour

The bean definitions are only created for top level classes.

Steps To Reproduce

It looks like the cause of this issue is either in BeanImportVisitor.java or JavaVisitorContext.java, one of them should handle enclosed elements.

Environment Information

No response

Example Application

No response

Version

3.8.0

auke- added a commit to auke-/micronaut-core that referenced this issue Jan 3, 2023
auke- added a commit to auke-/micronaut-core that referenced this issue Jan 19, 2023
auke- added a commit to auke-/micronaut-core that referenced this issue Jan 19, 2023
@graemerocher graemerocher added this to the 3.8.3 milestone Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants